亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
国模一区二区三区白浆| 欧美色倩网站大全免费| 一本一道综合狠狠老| 欧美一区二区在线观看| 国产精品青草综合久久久久99| 舔着乳尖日韩一区| aaa国产一区| 久久久蜜桃精品| 免费看欧美女人艹b| 欧美亚洲日本一区| 日韩理论片中文av| 国产99一区视频免费 | 久久亚洲综合色一区二区三区| 亚洲欧美激情插| 成人免费毛片app| 久久久九九九九| 激情文学综合丁香| 日韩欧美国产一二三区| 婷婷亚洲久悠悠色悠在线播放| 91美女片黄在线观看| 国产精品久久久久久户外露出| 国产一区二区三区高清播放| 3751色影院一区二区三区| 亚洲制服丝袜av| 色综合久久66| 亚洲激情图片小说视频| 91在线丨porny丨国产| 国产精品女主播在线观看| 高清在线成人网| 久久久久97国产精华液好用吗| 精品亚洲成a人在线观看| 日韩欧美成人一区| 九九精品视频在线看| 精品国产1区二区| 美女诱惑一区二区| 日韩免费高清av| 国内成人自拍视频| 中文字幕国产精品一区二区| 成人免费高清在线观看| 国产精品麻豆视频| 色综合久久综合| 一个色在线综合| 欧美视频你懂的| 免费欧美日韩国产三级电影| 欧美白人最猛性xxxxx69交| 国内精品嫩模私拍在线| 国产丝袜在线精品| 色综合久久综合网欧美综合网| 一区二区在线观看av| 欧美日韩三级一区| 久久9热精品视频| 欧美激情综合五月色丁香| av在线这里只有精品| 亚洲综合激情网| 日韩欧美激情四射| 丰满亚洲少妇av| 亚洲一二三四久久| 日韩免费看网站| av中文字幕在线不卡| 亚洲福利电影网| 久久亚洲精华国产精华液 | 精品国产91乱码一区二区三区| 国产一区二区免费看| ...av二区三区久久精品| 欧美三级一区二区| 国产福利一区在线| 亚洲国产精品一区二区www在线| 日韩亚洲欧美在线观看| 成人免费毛片嘿嘿连载视频| 午夜精彩视频在线观看不卡| 久久精子c满五个校花| 欧美伊人精品成人久久综合97| 激情五月婷婷综合网| 中文字幕亚洲区| 日韩视频123| 在线精品观看国产| 国产aⅴ综合色| 免费三级欧美电影| 亚洲欧洲综合另类在线 | 欧美日韩成人高清| 大胆亚洲人体视频| 理论电影国产精品| 亚洲国产成人av| 成人免费在线视频| 久久久久久97三级| 91精品国产福利在线观看| 99久久久久免费精品国产| 久久99久久久久久久久久久| 夜夜嗨av一区二区三区网页| 欧美国产在线观看| 欧美大片免费久久精品三p| 欧美视频一区二区三区四区| 成人av电影在线| 国产激情一区二区三区四区| 婷婷中文字幕综合| 亚洲最大的成人av| 亚洲欧美激情一区二区| 国产精品久久久久9999吃药| 久久久久久久久久久久久久久99| 777久久久精品| 欧美色精品天天在线观看视频| 97久久超碰国产精品| 国产成人午夜高潮毛片| 国产一区二区三区不卡在线观看| 欧美aaa在线| 美女性感视频久久| 日韩成人一区二区三区在线观看| 一区二区三区在线免费| 亚洲视频一区在线| 亚洲欧美日韩在线不卡| 国产精品毛片高清在线完整版| 久久精品一级爱片| 久久久91精品国产一区二区三区| 久久久亚洲综合| 国产欧美日韩综合精品一区二区| 久久久午夜精品| 国产精品丝袜91| 亚洲另类色综合网站| 亚洲久本草在线中文字幕| **欧美大码日韩| 亚洲国产精品自拍| 日韩不卡免费视频| 精油按摩中文字幕久久| 韩国女主播一区| 成人国产亚洲欧美成人综合网| 成人性生交大片免费| 99国产精品国产精品毛片| 欧美艳星brazzers| 日韩一区二区三区免费看| 久久一夜天堂av一区二区三区| 国产视频一区在线播放| 亚洲视频免费观看| 午夜精品影院在线观看| 九一久久久久久| youjizz久久| 欧美高清视频不卡网| 欧美成人国产一区二区| 国产欧美日韩激情| 亚洲自拍偷拍麻豆| 久久99久久久久| 99久久精品国产导航| 欧美日韩国产一级二级| 精品免费一区二区三区| 亚洲欧洲精品一区二区精品久久久| 亚洲永久免费av| 国产综合久久久久久鬼色 | 国产精品灌醉下药二区| 性久久久久久久久久久久| 激情亚洲综合在线| 色8久久人人97超碰香蕉987| 日韩一区二区三区视频| 国产精品热久久久久夜色精品三区| 亚洲二区在线观看| 福利一区二区在线观看| 欧美日韩国产系列| 欧美国产激情二区三区| 日韩av不卡在线观看| 成人免费va视频| 欧美va亚洲va在线观看蝴蝶网| 综合久久国产九一剧情麻豆| 麻豆成人91精品二区三区| 色婷婷一区二区三区四区| 精品国产伦理网| 亚洲成人激情自拍| 99国产精品国产精品久久| 久久久久久久久免费| 午夜精品一区在线观看| 一本大道久久精品懂色aⅴ| 欧美精品一区二区三区高清aⅴ| 一区二区三区不卡视频在线观看| 国产美女一区二区| 日韩午夜av一区| 亚洲午夜私人影院| 色欧美片视频在线观看在线视频| 久久久777精品电影网影网| 免费观看在线色综合| 欧美色图在线观看| 一区二区三区在线视频免费| 成人免费黄色大片| 国产欧美1区2区3区| 韩国成人在线视频| 日韩精品中午字幕| 蜜臀久久99精品久久久画质超高清| 色婷婷国产精品综合在线观看| 国产色91在线| 国产精品一区二区免费不卡| 精品久久久久久久人人人人传媒| 午夜激情久久久| 欧美日韩第一区日日骚| 一区二区三区自拍| 在线精品视频一区二区三四| 亚洲色图.com| 972aa.com艺术欧美| 综合久久久久综合| av不卡免费电影| 亚洲欧美日韩中文播放| 日本高清不卡在线观看| 亚洲综合色在线| 欧美乱熟臀69xxxxxx| 日韩精品电影在线|