亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? widget.py

?? Urwid is a Python library for making text console applications. It has many features including fluid
?? PY
?? 第 1 頁 / 共 5 頁
字號:
#!/usr/bin/python## Urwid basic widget classes#    Copyright (C) 2004-2007  Ian Ward##    This library is free software; you can redistribute it and/or#    modify it under the terms of the GNU Lesser General Public#    License as published by the Free Software Foundation; either#    version 2.1 of the License, or (at your option) any later version.##    This library is distributed in the hope that it will be useful,#    but WITHOUT ANY WARRANTY; without even the implied warranty of#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU#    Lesser General Public License for more details.##    You should have received a copy of the GNU Lesser General Public#    License along with this library; if not, write to the Free Software#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA## Urwid web site: http://excess.org/urwid/import stringfrom util import *from canvas import *try: sum # old python?except: sum = lambda l: reduce(lambda a,b: a+b, l, 0)class WidgetMeta(MetaSuper, MetaSignals):	"""	Automatic caching of render and rows methods.	Class variable no_cache is a list of names of methods to not cache.	Class variable ignore_focus if defined and True indicates that this	widget is not affected by the focus parameter, so it may be ignored	when caching.	"""	def __init__(cls, name, bases, d):		no_cache = d.get("no_cache", [])				super(WidgetMeta, cls).__init__(name, bases, d)		if "render" in d:			if "render" not in no_cache:				render_fn = cache_widget_render(cls)			else:				render_fn = nocache_widget_render(cls)			cls.render = render_fn		if "rows" in d and "rows" not in no_cache:			cls.rows = cache_widget_rows(cls)		if "no_cache" in d:			del cls.no_cache		if "ignore_focus" in d:			del cls.ignore_focusclass WidgetError(Exception):	passdef validate_size(widget, size, canv):	"""	Raise a WidgetError if a canv does not match size size.	"""	if (size and size[1:] != (0,) and size[0] != canv.cols()) or \		(len(size)>1 and size[1] != canv.rows()):		raise WidgetError("Widget %r rendered (%d x %d) canvas"			" when passed size %r!" % (widget, canv.cols(),			canv.rows(), size))def cache_widget_render(cls):	"""	Return a function that wraps the cls.render() method	and fetches and stores canvases with CanvasCache.	"""	ignore_focus = bool(getattr(cls, "ignore_focus", False))	fn = cls.render	def cached_render(self, size, focus=False):		focus = focus and not ignore_focus		canv = CanvasCache.fetch(self, cls, size, focus)		if canv:			return canv		canv = fn(self, size, focus=focus)		validate_size(self, size, canv)		if canv.widget_info:			canv = CompositeCanvas(canv)		canv.finalize(self, size, focus)		CanvasCache.store(cls, canv)		return canv	cached_render.original_fn = fn	return cached_renderdef nocache_widget_render(cls):	"""	Return a function that wraps the cls.render() method	and finalizes the canvas that it returns.	"""	fn = cls.render	if hasattr(fn, "original_fn"):		fn = fn.original_fn	def finalize_render(self, size, focus=False):		canv = fn(self, size, focus=focus)		if canv.widget_info:			canv = CompositeCanvas(canv)		validate_size(self, size, canv)		canv.finalize(self, size, focus)		return canv	finalize_render.original_fn = fn	return finalize_renderdef nocache_widget_render_instance(self):	"""	Return a function that wraps the cls.render() method	and finalizes the canvas that it returns, but does not 	cache the canvas.	"""	fn = self.render.original_fn	def finalize_render(size, focus=False):		canv = fn(self, size, focus=focus)		if canv.widget_info:			canv = CompositeCanvas(canv)		canv.finalize(self, size, focus)		return canv	finalize_render.original_fn = fn	return finalize_renderdef cache_widget_rows(cls):	"""	Return a function that wraps the cls.rows() method	and returns rows from the CanvasCache if available.	"""	ignore_focus = bool(getattr(cls, "ignore_focus", False))	fn = cls.rows	def cached_rows(self, size, focus=False):		focus = focus and not ignore_focus		canv = CanvasCache.fetch(self, cls, size, focus)		if canv:			return canv.rows()		return fn(self, size, focus)	return cached_rowsclass Widget(object):	"""	base class of widgets	"""	__metaclass__ = WidgetMeta	_selectable = False	def _invalidate(self):		CanvasCache.invalidate(self)	def _emit(self, name, *args):		Signals.emit(self, name, *args)		def selectable(self):		return self._selectable	class FlowWidget(Widget):	"""	base class of widgets	"""	def rows(self, (maxcol,), focus=False):		"""		All flow widgets must implement this function.		"""		raise NotImplementedError()	def render(self, (maxcol,), focus=False):		"""		All widgets must implement this function.		"""		raise NotImplementedError()class BoxWidget(Widget):	"""	base class of width and height constrained widgets such as	the top level widget attached to the display object	"""	_selectable = True		def render(self, size, focus=False):		"""		All widgets must implement this function.		"""		raise NotImplementedError()	def fixed_size(size):	"""	raise ValueError if size != ().		Used by FixedWidgets to test size parameter.	"""	if size != ():		raise ValueError("FixedWidget takes only () for size." \			"passed: %s" % `size`)class FixedWidget(Widget):	"""	base class of widgets that know their width and height and	cannot be resized	"""	def render(self, size, focus=False):		"""		All widgets must implement this function.		"""		raise NotImplementedError()		def pack(self, size=None, focus=False):		"""		All fixed widgets must implement this function.		"""		raise NotImplementedError()class Divider(FlowWidget):	"""	Horizontal divider widget	"""	ignore_focus = True	def __init__(self,div_char=" ",top=0,bottom=0):		"""		div_char -- character to repeat across line		top -- number of blank lines above		bottom -- number of blank lines below		"""		self.__super.__init__()		self.div_char = div_char		self.top = top		self.bottom = bottom				def rows(self, (maxcol,), focus=False):		"""Return the number of lines that will be rendered."""		return self.top + 1 + self.bottom		def render(self, (maxcol,), focus=False):		"""Render the divider as a canvas and return it."""		canv = SolidCanvas(self.div_char, maxcol, 1)		canv = CompositeCanvas(canv)		if self.top or self.bottom:			canv.pad_trim_top_bottom(self.top, self.bottom)		return canv	class SolidFill(BoxWidget):	_selectable = False	ignore_focus = True	def __init__(self,fill_char=" "):		"""		fill_char -- character to fill area with		"""		self.__super.__init__()		self.fill_char = fill_char		def render(self,(maxcol,maxrow), focus=False ):		"""Render the Fill as a canvas and return it."""		return SolidCanvas(self.fill_char, maxcol, maxrow)	class TextError(Exception):	passclass Text(FlowWidget):	"""	a horizontally resizeable text widget	"""	ignore_focus = True	def __init__(self,markup, align='left', wrap='space', layout=None):		"""		markup -- content of text widget, one of:			plain string -- string is displayed			( attr, markup2 ) -- markup2 is given attribute attr			[ markupA, markupB, ... ] -- list items joined together		align -- align mode for text layout		wrap -- wrap mode for text layout		layout -- layout object to use, defaults to StandardTextLayout		"""		self.__super.__init__()		self._cache_maxcol = None		self.set_text(markup)		self.set_layout(align, wrap, layout)		def _invalidate(self):		self._cache_maxcol = None		self.__super._invalidate()	def set_text(self,markup):		"""Set content of text widget."""		self.text, self.attrib = decompose_tagmarkup(markup)		self._invalidate()	def get_text(self):		"""		Returns (text, attributes).				text -- complete string content of text widget		attributes -- run length encoded attributes for text		"""		return self.text, self.attrib	def set_align_mode(self, mode):		"""		Set text alignment / justification.  				Valid modes for StandardTextLayout are: 			'left', 'center' and 'right'		"""		if not self.layout.supports_align_mode(mode):			raise TextError("Alignment mode %s not supported."%				`mode`)		self.align_mode = mode		self._invalidate()	def set_wrap_mode(self, mode):		"""		Set wrap mode.  				Valid modes for StandardTextLayout are :			'any'	: wrap at any character			'space'	: wrap on space character			'clip'	: truncate lines instead of wrapping		"""		if not self.layout.supports_wrap_mode(mode):			raise TextError("Wrap mode %s not supported"%`mode`)		self.wrap_mode = mode		self._invalidate()	def set_layout(self, align, wrap, layout=None):		"""		Set layout object, align and wrap modes.				align -- align mode for text layout		wrap -- wrap mode for text layout		layout -- layout object to use, defaults to StandardTextLayout		"""		if layout is None:			layout = default_layout		self.layout = layout		self.set_align_mode( align )		self.set_wrap_mode( wrap )	def render(self,(maxcol,), focus=False):		"""		Render contents with wrapping and alignment.  Return canvas.		"""		text, attr = self.get_text()		trans = self.get_line_translation( maxcol, (text,attr) )		return apply_text_layout(text, attr, trans, maxcol)	def rows(self,(maxcol,), focus=False):		"""Return the number of rows the rendered text spans."""		return len(self.get_line_translation(maxcol))	def get_line_translation(self, maxcol, ta=None):		"""Return layout structure for mapping self.text to a canvas.		"""		if not self._cache_maxcol or self._cache_maxcol != maxcol:			self._update_cache_translation(maxcol, ta)		return self._cache_translation	def _update_cache_translation(self,maxcol, ta):		if ta:			text, attr = ta		else:			text, attr = self.get_text()		self._cache_maxcol = maxcol		self._cache_translation = self._calc_line_translation(			text, maxcol )		def _calc_line_translation(self, text, maxcol ):		return self.layout.layout(			text, self._cache_maxcol, 			self.align_mode, self.wrap_mode )		def pack(self, size=None, focus=False):		"""		Return the number of screen columns required for this Text		widget to be displayed without wrapping or clipping, as a 		single element tuple.		size -- None for unlimited screen columns or (maxcol,) to		        specify a maximum column size		"""		text, attr = self.get_text()				if size is not None:			(maxcol,) = size			if not hasattr(self.layout, "pack"):				return size			trans = self.get_line_translation( maxcol, (text,attr))			cols = self.layout.pack( maxcol, trans )			return (cols,)			i = 0		cols = 0		while i < len(text):			j = text.find('\n', i)			if j == -1:				j = len(text)			c = calc_width(text, i, j)			if c>cols:				cols = c			i = j+1		return (cols,)		class Edit(Text):	"""Text edit widget"""		def valid_char(self, ch):		"""Return true for printable characters."""		return is_wide_char(ch,0) or (len(ch)==1 and ord(ch) >= 32)		def selectable(self): return True	def __init__(self, caption = "", edit_text = "", multiline = False,			align = 'left', wrap = 'space', allow_tab = False,			edit_pos = None, layout=None):		"""		caption -- markup for caption preceeding edit_text		edit_text -- text string for editing		multiline -- True: 'enter' inserts newline  False: return it		align -- align mode		wrap -- wrap mode		allow_tab -- True: 'tab' inserts 1-8 spaces  False: return it		edit_pos -- initial position for cursor, None:at end		layout -- layout object		"""				self.__super.__init__("", align, wrap, layout)		assert type(edit_text)==type("") or type(edit_text)==type(u"")		self.multiline = multiline		self.allow_tab = allow_tab		self.edit_pos = 0		self.set_caption(caption)		self.set_edit_text(edit_text)		if edit_pos is None:			edit_pos = len(edit_text)		self.set_edit_pos(edit_pos)		self._shift_view_to_cursor = False		def get_text(self):		"""get_text() -> text, attributes				text -- complete text of caption and edit_text		attributes -- run length encoded attributes for text		"""		return self.caption + self.edit_text, self.attrib		def get_pref_col(self, (maxcol,)):		"""Return the preferred column for the cursor, or the		current cursor x value."""		pref_col, then_maxcol = self.pref_col_maxcol		if then_maxcol != maxcol:			return self.get_cursor_coords((maxcol,))[0]		else:			return pref_col		def update_text(self):		"""Deprecated.  Use set_caption and/or set_edit_text instead.				Make sure any cached line translation is not reused."""		self._invalidate()	def set_caption(self, caption):		"""Set the caption markup for this widget."""

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产一区久久| 亚洲欧美电影一区二区| 久久夜色精品国产噜噜av| 亚洲电影第三页| 亚洲欧美日韩国产一区二区三区 | 风间由美一区二区av101| 99re亚洲国产精品| 宅男在线国产精品| 国产精品麻豆99久久久久久| 亚洲一区二区三区不卡国产欧美| 日本午夜一本久久久综合| 日韩精品成人一区二区三区| 日本色综合中文字幕| 99视频有精品| 久久综合九色综合欧美98 | 欧美日韩电影一区| 国产日韩成人精品| 一区二区成人在线观看| 免费久久99精品国产| 色婷婷综合久色| 欧美精品一区二区在线观看| 亚洲一区国产视频| 国产98色在线|日韩| 91精品中文字幕一区二区三区| 亚洲国产激情av| 久久国产夜色精品鲁鲁99| 一本到高清视频免费精品| 久久久久久久性| 日本欧美肥老太交大片| 91污在线观看| 欧美激情综合网| 精品影视av免费| 欧美一区二区精品久久911| 久久国内精品自在自线400部| 色噜噜夜夜夜综合网| 国产精品久久久久精k8| 国产激情视频一区二区三区欧美 | 欧美激情一区三区| 另类专区欧美蜜桃臀第一页| 欧美视频完全免费看| 中文字幕日韩一区二区| 日本视频一区二区三区| 69久久99精品久久久久婷婷| 亚洲午夜羞羞片| 欧美性猛交一区二区三区精品| 亚洲男人天堂一区| 色综合久久中文字幕| 亚洲人成网站色在线观看| 国产成人欧美日韩在线电影| 久久久久国产精品人| 国产精品456露脸| 久久精品亚洲麻豆av一区二区 | 51精品国自产在线| 一区二区三区免费| 欧美午夜精品理论片a级按摩| 一区二区三区四区在线播放| 欧美亚洲禁片免费| 亚洲主播在线播放| 欧美日韩午夜在线| 日本不卡一区二区| 精品精品国产高清一毛片一天堂| 精品一区二区三区蜜桃| 精品国产凹凸成av人网站| 国产成人av影院| 中文字幕免费观看一区| 99国产精品久久久久| 一区二区三区在线视频观看58| 久久久久久99精品| av在线免费不卡| 亚洲一区二区成人在线观看| 欧美欧美午夜aⅴ在线观看| 喷水一区二区三区| 国产欧美一区二区在线| 99re66热这里只有精品3直播| 亚洲午夜羞羞片| 欧美变态口味重另类| 成人免费高清在线| 夜夜嗨av一区二区三区中文字幕| 7777精品伊人久久久大香线蕉超级流畅| 美女国产一区二区| 国产精品国产三级国产| 欧美日韩一区二区欧美激情| 经典三级视频一区| 亚洲欧美综合色| 欧美日韩日日骚| 国产精品一级黄| 亚洲自拍偷拍九九九| 精品久久人人做人人爽| 91日韩精品一区| 久久99精品国产麻豆不卡| 久久久久久亚洲综合影院红桃 | 成人黄色av网站在线| 亚洲二区视频在线| 欧美精品色综合| 精品系列免费在线观看| 亚洲天堂福利av| 日韩美女视频在线| 在线视频中文字幕一区二区| 国产一区二区三区在线观看免费视频| 一区二区三区视频在线看| 久久久久久免费| 欧美精品日韩综合在线| 欧美mv和日韩mv的网站| 91啪在线观看| 高清国产午夜精品久久久久久| 亚洲成av人片| 自拍偷拍亚洲综合| www久久精品| 99久久久久久| 国产伦精品一区二区三区免费迷| 亚洲大片精品永久免费| 国产精品网站在线观看| 精品福利一二区| 欧美一级二级三级乱码| 精品久久人人做人人爱| 欧美肥妇bbw| 日韩欧美在线网站| 欧美一区二区性放荡片| 欧美一区二区精品| 日韩欧美一级二级三级久久久| 日韩一区二区电影在线| 日韩精品一区二区三区四区| 日韩欧美国产三级| 久久久欧美精品sm网站| 国产精品色一区二区三区| 日韩一区欧美小说| 亚洲精选视频免费看| 亚洲一区二区在线免费看| 亚洲第一会所有码转帖| 日本特黄久久久高潮| 国产一区不卡在线| 成人激情图片网| 色哟哟一区二区在线观看| 欧美三级韩国三级日本三斤| 717成人午夜免费福利电影| 日韩精品一区二| 国产精品色在线观看| 亚洲午夜一区二区| 久久99国产精品尤物| 成人免费黄色大片| 久久综合久久综合久久综合| 国产精品久久福利| 香蕉久久一区二区不卡无毒影院 | 久久九九影视网| 亚洲欧美日韩国产成人精品影院 | 亚洲精品视频一区| 天堂精品中文字幕在线| 国产盗摄一区二区| 欧美性生活久久| 久久午夜国产精品| 一区二区三区高清在线| 精品亚洲porn| 91黄色激情网站| 久久精品欧美一区二区三区麻豆| 亚洲色图.com| 久久99国产精品久久99果冻传媒| av在线一区二区| 日韩精品综合一本久道在线视频| 国产精品你懂的在线欣赏| 视频一区视频二区中文| 不卡电影免费在线播放一区| 91精品国产综合久久久蜜臀粉嫩| 国产精品久久福利| 久久99国产乱子伦精品免费| 一本一本久久a久久精品综合麻豆| 欧美v日韩v国产v| 一二三四区精品视频| 成人av在线电影| 精品对白一区国产伦| 亚洲二区视频在线| 99久久亚洲一区二区三区青草| 日韩午夜av电影| 亚洲国产精品一区二区久久恐怖片| 国产麻豆一精品一av一免费 | 4438亚洲最大| 亚洲在线中文字幕| www.激情成人| 久久免费电影网| 久久99久久99| 91麻豆精品国产自产在线观看一区| 亚洲欧美电影院| 99久久婷婷国产| 国产精品高潮久久久久无| 国产麻豆午夜三级精品| 日韩一区二区麻豆国产| 性做久久久久久免费观看欧美| 91免费精品国自产拍在线不卡| 国产欧美一区二区精品忘忧草| 狠狠色丁香久久婷婷综合_中| 69堂成人精品免费视频| 亚洲成人动漫在线观看| 91国产免费观看| 亚洲精品免费视频| 92国产精品观看| 国产精品乱人伦一区二区| 国产成人免费9x9x人网站视频| 国产午夜精品一区二区三区视频| 久久国产福利国产秒拍| 欧美成人高清电影在线| 久久99国产乱子伦精品免费|