⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tkinter.py

📁 minimal python variant for small footprint apps like embedded apps
💻 PY
📖 第 1 页 / 共 5 页
字号:
		self.tk.call(self._w, 'bind', tagOrId, sequence, '')		if funcid:			self.deletecommand(funcid)	def tag_bind(self, tagOrId, sequence=None, func=None, add=None):		return self._bind((self._w, 'bind', tagOrId),				  sequence, func, add)	def canvasx(self, screenx, gridspacing=None):		return getdouble(self.tk.call(			self._w, 'canvasx', screenx, gridspacing))	def canvasy(self, screeny, gridspacing=None):		return getdouble(self.tk.call(			self._w, 'canvasy', screeny, gridspacing))	def coords(self, *args):		# XXX Should use _flatten on args		return map(getdouble,                           self.tk.splitlist(				   self.tk.call((self._w, 'coords') + args)))	def _create(self, itemType, args, kw): # Args: (val, val, ..., cnf={})		args = _flatten(args)		cnf = args[-1]		if type(cnf) in (DictionaryType, TupleType):			args = args[:-1]		else:			cnf = {}		return getint(apply(			self.tk.call,			(self._w, 'create', itemType) 			+ args + self._options(cnf, kw)))	def create_arc(self, *args, **kw):		return self._create('arc', args, kw)	def create_bitmap(self, *args, **kw):		return self._create('bitmap', args, kw)	def create_image(self, *args, **kw):		return self._create('image', args, kw)	def create_line(self, *args, **kw):		return self._create('line', args, kw)	def create_oval(self, *args, **kw):		return self._create('oval', args, kw)	def create_polygon(self, *args, **kw):		return self._create('polygon', args, kw)	def create_rectangle(self, *args, **kw):		return self._create('rectangle', args, kw)	def create_text(self, *args, **kw):		return self._create('text', args, kw)	def create_window(self, *args, **kw):		return self._create('window', args, kw)	def dchars(self, *args):		self.tk.call((self._w, 'dchars') + args)	def delete(self, *args):		self.tk.call((self._w, 'delete') + args)	def dtag(self, *args):		self.tk.call((self._w, 'dtag') + args)	def find(self, *args):		return self._getints(			self.tk.call((self._w, 'find') + args)) or ()	def find_above(self, tagOrId):		return self.find('above', tagOrId)	def find_all(self):		return self.find('all')	def find_below(self, tagOrId):		return self.find('below', tagOrId)	def find_closest(self, x, y, halo=None, start=None):		return self.find('closest', x, y, halo, start)	def find_enclosed(self, x1, y1, x2, y2):		return self.find('enclosed', x1, y1, x2, y2)	def find_overlapping(self, x1, y1, x2, y2):		return self.find('overlapping', x1, y1, x2, y2)	def find_withtag(self, tagOrId):		return self.find('withtag', tagOrId)	def focus(self, *args):		return self.tk.call((self._w, 'focus') + args)	def gettags(self, *args):		return self.tk.splitlist(			self.tk.call((self._w, 'gettags') + args))	def icursor(self, *args):		self.tk.call((self._w, 'icursor') + args)	def index(self, *args):		return getint(self.tk.call((self._w, 'index') + args))	def insert(self, *args):		self.tk.call((self._w, 'insert') + args)	def itemcget(self, tagOrId, option):		return self.tk.call(			(self._w, 'itemcget') + (tagOrId, '-'+option))	def itemconfigure(self, tagOrId, cnf=None, **kw):		if cnf is None and not kw:			cnf = {}			for x in self.tk.split(				self.tk.call(self._w,					     'itemconfigure', tagOrId)):				cnf[x[0][1:]] = (x[0][1:],) + x[1:]			return cnf		if type(cnf) == StringType and not kw:			x = self.tk.split(self.tk.call(				self._w, 'itemconfigure', tagOrId, '-'+cnf))			return (x[0][1:],) + x[1:]		self.tk.call((self._w, 'itemconfigure', tagOrId) +			     self._options(cnf, kw))	itemconfig = itemconfigure	# lower, tkraise/lift hide Misc.lower, Misc.tkraise/lift,	# so the preferred name for them is tag_lower, tag_raise	# (similar to tag_bind, and similar to the Text widget);	# unfortunately can't delete the old ones yet (maybe in 1.6)	def tag_lower(self, *args):		self.tk.call((self._w, 'lower') + args)	lower = tag_lower	def move(self, *args):		self.tk.call((self._w, 'move') + args)	def postscript(self, cnf={}, **kw):		return self.tk.call((self._w, 'postscript') +				    self._options(cnf, kw))	def tag_raise(self, *args):		self.tk.call((self._w, 'raise') + args)	lift = tkraise = tag_raise	def scale(self, *args):		self.tk.call((self._w, 'scale') + args)	def scan_mark(self, x, y):		self.tk.call(self._w, 'scan', 'mark', x, y)	def scan_dragto(self, x, y):		self.tk.call(self._w, 'scan', 'dragto', x, y)	def select_adjust(self, tagOrId, index):		self.tk.call(self._w, 'select', 'adjust', tagOrId, index)	def select_clear(self):		self.tk.call(self._w, 'select', 'clear')	def select_from(self, tagOrId, index):		self.tk.call(self._w, 'select', 'from', tagOrId, index)	def select_item(self):		self.tk.call(self._w, 'select', 'item')	def select_to(self, tagOrId, index):		self.tk.call(self._w, 'select', 'to', tagOrId, index)	def type(self, tagOrId):		return self.tk.call(self._w, 'type', tagOrId) or None	def xview(self, *args):		if not args:			return self._getdoubles(self.tk.call(self._w, 'xview'))		self.tk.call((self._w, 'xview') + args)	def xview_moveto(self, fraction):		self.tk.call(self._w, 'xview', 'moveto', fraction)	def xview_scroll(self, number, what):		self.tk.call(self._w, 'xview', 'scroll', number, what)	def yview(self, *args):		if not args:			return self._getdoubles(self.tk.call(self._w, 'yview'))		self.tk.call((self._w, 'yview') + args)	def yview_moveto(self, fraction):		self.tk.call(self._w, 'yview', 'moveto', fraction)	def yview_scroll(self, number, what):		self.tk.call(self._w, 'yview', 'scroll', number, what)class Checkbutton(Widget):	def __init__(self, master=None, cnf={}, **kw):		Widget.__init__(self, master, 'checkbutton', cnf, kw)	def deselect(self):		self.tk.call(self._w, 'deselect')	def flash(self):		self.tk.call(self._w, 'flash')	def invoke(self):		return self.tk.call(self._w, 'invoke')	def select(self):		self.tk.call(self._w, 'select')	def toggle(self):		self.tk.call(self._w, 'toggle')class Entry(Widget):	def __init__(self, master=None, cnf={}, **kw):		Widget.__init__(self, master, 'entry', cnf, kw)	def delete(self, first, last=None):		self.tk.call(self._w, 'delete', first, last)	def get(self):		return self.tk.call(self._w, 'get')	def icursor(self, index):		self.tk.call(self._w, 'icursor', index)	def index(self, index):		return getint(self.tk.call(			self._w, 'index', index))	def insert(self, index, string):		self.tk.call(self._w, 'insert', index, string)	def scan_mark(self, x):		self.tk.call(self._w, 'scan', 'mark', x)	def scan_dragto(self, x):		self.tk.call(self._w, 'scan', 'dragto', x)	def selection_adjust(self, index):		self.tk.call(self._w, 'selection', 'adjust', index)	select_adjust = selection_adjust	def selection_clear(self):		self.tk.call(self._w, 'selection', 'clear')	select_clear = selection_clear	def selection_from(self, index):		self.tk.call(self._w, 'selection', 'from', index)	select_from = selection_from	def selection_present(self):		return self.tk.getboolean(			self.tk.call(self._w, 'selection', 'present'))	select_present = selection_present	def selection_range(self, start, end):		self.tk.call(self._w, 'selection', 'range', start, end)	select_range = selection_range	def selection_to(self, index):		self.tk.call(self._w, 'selection', 'to', index)	select_to = selection_to	def xview(self, index):		self.tk.call(self._w, 'xview', index)	def xview_moveto(self, fraction):		self.tk.call(self._w, 'xview', 'moveto', fraction)	def xview_scroll(self, number, what):		self.tk.call(self._w, 'xview', 'scroll', number, what)class Frame(Widget):	def __init__(self, master=None, cnf={}, **kw):		cnf = _cnfmerge((cnf, kw))		extra = ()		if cnf.has_key('class_'):			extra = ('-class', cnf['class_'])			del cnf['class_']		elif cnf.has_key('class'):			extra = ('-class', cnf['class'])			del cnf['class']		Widget.__init__(self, master, 'frame', cnf, {}, extra)class Label(Widget):	def __init__(self, master=None, cnf={}, **kw):		Widget.__init__(self, master, 'label', cnf, kw)class Listbox(Widget):	def __init__(self, master=None, cnf={}, **kw):		Widget.__init__(self, master, 'listbox', cnf, kw)	def activate(self, index):		self.tk.call(self._w, 'activate', index)	def bbox(self, *args):		return self._getints(			self.tk.call((self._w, 'bbox') + args)) or None	def curselection(self):		# XXX Ought to apply self._getints()...		return self.tk.splitlist(self.tk.call(			self._w, 'curselection'))	def delete(self, first, last=None):		self.tk.call(self._w, 'delete', first, last)	def get(self, first, last=None):		if last:			return self.tk.splitlist(self.tk.call(				self._w, 'get', first, last))		else:			return self.tk.call(self._w, 'get', first)	def index(self, index):		i = self.tk.call(self._w, 'index', index)		if i == 'none': return None		return getint(i)	def insert(self, index, *elements):		self.tk.call((self._w, 'insert', index) + elements)	def nearest(self, y):		return getint(self.tk.call(			self._w, 'nearest', y))	def scan_mark(self, x, y):		self.tk.call(self._w, 'scan', 'mark', x, y)	def scan_dragto(self, x, y):		self.tk.call(self._w, 'scan', 'dragto', x, y)	def see(self, index):		self.tk.call(self._w, 'see', index)	def selection_anchor(self, index):		self.tk.call(self._w, 'selection', 'anchor', index)	select_anchor = selection_anchor	def selection_clear(self, first, last=None):		self.tk.call(self._w,			     'selection', 'clear', first, last)	select_clear = selection_clear	def selection_includes(self, index):		return self.tk.getboolean(self.tk.call(			self._w, 'selection', 'includes', index))	select_includes = selection_includes	def selection_set(self, first, last=None):		self.tk.call(self._w, 'selection', 'set', first, last)	select_set = selection_set	def size(self):		return getint(self.tk.call(self._w, 'size'))	def xview(self, *what):		if not what:			return self._getdoubles(self.tk.call(self._w, 'xview'))		self.tk.call((self._w, 'xview') + what)	def xview_moveto(self, fraction):		self.tk.call(self._w, 'xview', 'moveto', fraction)	def xview_scroll(self, number, what):		self.tk.call(self._w, 'xview', 'scroll', number, what)	def yview(self, *what):		if not what:			return self._getdoubles(self.tk.call(self._w, 'yview'))		self.tk.call((self._w, 'yview') + what)	def yview_moveto(self, fraction):		self.tk.call(self._w, 'yview', 'moveto', fraction)	def yview_scroll(self, number, what):		self.tk.call(self._w, 'yview', 'scroll', number, what)class Menu(Widget):	def __init__(self, master=None, cnf={}, **kw):		Widget.__init__(self, master, 'menu', cnf, kw)	def tk_bindForTraversal(self):		pass # obsolete since Tk 4.0	def tk_mbPost(self):		self.tk.call('tk_mbPost', self._w)	def tk_mbUnpost(self):		self.tk.call('tk_mbUnpost')	def tk_traverseToMenu(self, char):		self.tk.call('tk_traverseToMenu', self._w, char)	def tk_traverseWithinMenu(self, char):		self.tk.call('tk_traverseWithinMenu', self._w, char)	def tk_getMenuButtons(self):		return self.tk.call('tk_getMenuButtons', self._w)	def tk_nextMenu(self, count):		self.tk.call('tk_nextMenu', count)	def tk_nextMenuEntry(self, count):		self.tk.call('tk_nextMenuEntry', count)	def tk_invokeMenu(self):		self.tk.call('tk_invokeMenu', self._w)	def tk_firstMenu(self):		self.tk.call('tk_firstMenu', self._w)	def tk_mbButtonDown(self):		self.tk.call('tk_mbButtonDown', self._w)	def tk_popup(self, x, y, entry=""):		self.tk.call('tk_popup', self._w, x, y, entry)	def activate(self, index):		self.tk.call(self._w, 'activate', index)	def add(self, itemType, cnf={}, **kw):		self.tk.call((self._w, 'add', itemType) +			     self._options(cnf, kw))	def add_cascade(self, cnf={}, **kw):		self.add('cascade', cnf or kw)	def add_checkbutton(self, cnf={}, **kw):		self.add('checkbutton', cnf or kw)	def add_command(self, cnf={}, **kw):		self.add('command', cnf or kw)	def add_radiobutton(self, cnf={}, **kw):		self.add('radiobutton', cnf or kw)	def add_separator(self, cnf={}, **kw):		self.add('separator', cnf or kw)	def insert(self, index, itemType, cnf={}, **kw):		self.tk.call((self._w, 'insert', index, itemType) +			     self._options(cnf, kw))	def insert_cascade(self, index, cnf={}, **kw):		self.insert(index, 'cascade', cnf or kw)	def insert_checkbutton(self, index, cnf={}, **kw):		self.insert(index, 'checkbutton', cnf or kw)	def insert_command(self, index, cnf={}, **kw):		self.insert(index, 'command', cnf or kw)	def insert_radiobutton(self, index, cnf={}, **kw):		self.insert(index, 'radiobutton', cnf or kw)	def insert_separator(self, index, cnf={}, **kw):		self.insert(index, 'separator', cnf or kw)	def delete(self, index1, index2=None):		self.tk.call(self._w, 'delete', index1, index2)	def entrycget(self, index, option):		return self.tk.call(self._w, 'entrycget', index, '-' + option)	def entryconfigure(self, index, cnf=None, **kw):		if cnf is None and not kw:			cnf = {}			for x in self.tk.split(self.tk.call(				(self._w, 'entryconfigure', index))):				cnf[x[0][1:]] = (x[0][1:],) + x[1:]			return cnf		if type(cnf) == StringType and not kw:			x = self.tk.split(self.tk.call(				(self._w, 'entryconfigure', index, '-'+cnf)))			return (x[0][1:],) + x[1:]		self.tk.call((self._w, 'entryconfigure', index)		      + self._options(cnf, kw))	entryconfig = entryconfigure	def index(self, index):		i = self.tk.call(self._w, 'index', index)		if i == 'none': return None		return getint(i)	def invoke(self, index):		return self.tk.call(self._w, 'invoke', index)	def post(self, x, y):		self.tk.call(self._w, 'post', x, y)	def type(self, index):		return self.tk.call(self._w, 'type', index)	def unpost(self):		self.tk.call(self._w, 'unpost')	def yposition(self, index):		return getint(self.tk.call(			self._w, 'yposition', index))class Menubutton(Widget):	def __init__(self, master=None, cnf={}, **kw):		Widget.__init__(self, master, 'menubutton', cnf, kw)class Message(Widget):	def __init__(self, master=None, cnf={}, **kw):		Widget.__init__(self, master, 'message', cnf, kw)class Radiobutton(Widget):	def __init__(self, master=None, cnf={}, **kw):		Widget.__init__(self, master, 'radiobutton', cnf, kw)	def deselect(self):		self.tk.call(self._w, 'deselect')	def flash(self):		self.tk.call(self._w, 'flash')	def invoke(self):		return self.tk.call(self._w, 'invoke')

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -