desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Return the next widget in the focus order which follows widget which has currently the focus. The focus order first goes to the next child, then to the children of the child recursively and then to the next sibling which is higher in the stacking order. A widget is omitted if it has the takefocus resource set to 0.'
def tk_focusNext(self):
name = self.tk.call('tk_focusNext', self._w) if (not name): return None return self._nametowidget(name)
'Return previous widget in the focus order. See tk_focusNext for details.'
def tk_focusPrev(self):
name = self.tk.call('tk_focusPrev', self._w) if (not name): return None return self._nametowidget(name)
'Call function once after given time. MS specifies the time in milliseconds. FUNC gives the function which shall be called. Additional parameters are given as parameters to the function call. Return identifier to cancel scheduling with after_cancel.'
def after(self, ms, func=None, *args):
if (not func): self.tk.call('after', ms) else: def callit(): try: func(*args) finally: try: self.deletecommand(name) except TclError: pass name = self._register(callit) return self.tk.call('after', ms, name)
'Call FUNC once if the Tcl main loop has no event to process. Return an identifier to cancel the scheduling with after_cancel.'
def after_idle(self, func, *args):
return self.after('idle', func, *args)
'Cancel scheduling of function identified with ID. Identifier returned by after or after_idle must be given as first parameter.'
def after_cancel(self, id):
try: data = self.tk.call('after', 'info', id) script = self.tk.splitlist(data)[0] self.deletecommand(script) except TclError: pass self.tk.call('after', 'cancel', id)
'Ring a display\'s bell.'
def bell(self, displayof=0):
self.tk.call((('bell',) + self._displayof(displayof)))
'Retrieve data from the clipboard on window\'s display. The window keyword defaults to the root window of the Tkinter application. The type keyword specifies the form in which the data is to be returned and should be an atom name such as STRING or FILE_NAME. Type defaults to STRING. This command is equivalent to: selection_get(CLIPBOARD)'
def clipboard_get(self, **kw):
return self.tk.call((('clipboard', 'get') + self._options(kw)))
'Clear the data in the Tk clipboard. A widget specified for the optional displayof keyword argument specifies the target display.'
def clipboard_clear(self, **kw):
if ('displayof' not in kw): kw['displayof'] = self._w self.tk.call((('clipboard', 'clear') + self._options(kw)))
'Append STRING to the Tk clipboard. A widget specified at the optional displayof keyword argument specifies the target display. The clipboard can be retrieved with selection_get.'
def clipboard_append(self, string, **kw):
if ('displayof' not in kw): kw['displayof'] = self._w self.tk.call(((('clipboard', 'append') + self._options(kw)) + ('--', string)))
'Return widget which has currently the grab in this application or None.'
def grab_current(self):
name = self.tk.call('grab', 'current', self._w) if (not name): return None return self._nametowidget(name)
'Release grab for this widget if currently set.'
def grab_release(self):
self.tk.call('grab', 'release', self._w)
'Set grab for this widget. A grab directs all events to this and descendant widgets in the application.'
def grab_set(self):
self.tk.call('grab', 'set', self._w)
'Set global grab for this widget. A global grab directs all events to this and descendant widgets on the display. Use with caution - other applications do not get events anymore.'
def grab_set_global(self):
self.tk.call('grab', 'set', '-global', self._w)
'Return None, "local" or "global" if this widget has no, a local or a global grab.'
def grab_status(self):
status = self.tk.call('grab', 'status', self._w) if (status == 'none'): status = None return status
'Set a VALUE (second parameter) for an option PATTERN (first parameter). An optional third parameter gives the numeric priority (defaults to 80).'
def option_add(self, pattern, value, priority=None):
self.tk.call('option', 'add', pattern, value, priority)
'Clear the option database. It will be reloaded if option_add is called.'
def option_clear(self):
self.tk.call('option', 'clear')
'Return the value for an option NAME for this widget with CLASSNAME. Values with higher priority override lower values.'
def option_get(self, name, className):
return self.tk.call('option', 'get', self._w, name, className)
'Read file FILENAME into the option database. An optional second parameter gives the numeric priority.'
def option_readfile(self, fileName, priority=None):
self.tk.call('option', 'readfile', fileName, priority)
'Clear the current X selection.'
def selection_clear(self, **kw):
if ('displayof' not in kw): kw['displayof'] = self._w self.tk.call((('selection', 'clear') + self._options(kw)))
'Return the contents of the current X selection. A keyword parameter selection specifies the name of the selection and defaults to PRIMARY. A keyword parameter displayof specifies a widget on the display to use.'
def selection_get(self, **kw):
if ('displayof' not in kw): kw['displayof'] = self._w return self.tk.call((('selection', 'get') + self._options(kw)))
'Specify a function COMMAND to call if the X selection owned by this widget is queried by another application. This function must return the contents of the selection. The function will be called with the arguments OFFSET and LENGTH which allows the chunking of very long selections. The following keyword parameters can be provided: selection - name of the selection (default PRIMARY), type - type of the selection (e.g. STRING, FILE_NAME).'
def selection_handle(self, command, **kw):
name = self._register(command) self.tk.call(((('selection', 'handle') + self._options(kw)) + (self._w, name)))
'Become owner of X selection. A keyword parameter selection specifies the name of the selection (default PRIMARY).'
def selection_own(self, **kw):
self.tk.call(((('selection', 'own') + self._options(kw)) + (self._w,)))
'Return owner of X selection. The following keyword parameter can be provided: selection - name of the selection (default PRIMARY), type - type of the selection (e.g. STRING, FILE_NAME).'
def selection_own_get(self, **kw):
if ('displayof' not in kw): kw['displayof'] = self._w name = self.tk.call((('selection', 'own') + self._options(kw))) if (not name): return None return self._nametowidget(name)
'Send Tcl command CMD to different interpreter INTERP to be executed.'
def send(self, interp, cmd, *args):
return self.tk.call((('send', interp, cmd) + args))
'Lower this widget in the stacking order.'
def lower(self, belowThis=None):
self.tk.call('lower', self._w, belowThis)
'Raise this widget in the stacking order.'
def tkraise(self, aboveThis=None):
self.tk.call('raise', self._w, aboveThis)
'Useless. Not implemented in Tk.'
def colormodel(self, value=None):
return self.tk.call('tk', 'colormodel', self._w, value)
'Return integer which represents atom NAME.'
def winfo_atom(self, name, displayof=0):
args = ((('winfo', 'atom') + self._displayof(displayof)) + (name,)) return getint(self.tk.call(args))
'Return name of atom with identifier ID.'
def winfo_atomname(self, id, displayof=0):
args = ((('winfo', 'atomname') + self._displayof(displayof)) + (id,)) return self.tk.call(args)
'Return number of cells in the colormap for this widget.'
def winfo_cells(self):
return getint(self.tk.call('winfo', 'cells', self._w))
'Return a list of all widgets which are children of this widget.'
def winfo_children(self):
result = [] for child in self.tk.splitlist(self.tk.call('winfo', 'children', self._w)): try: result.append(self._nametowidget(child)) except KeyError: pass return result
'Return window class name of this widget.'
def winfo_class(self):
return self.tk.call('winfo', 'class', self._w)
'Return true if at the last color request the colormap was full.'
def winfo_colormapfull(self):
return self.tk.getboolean(self.tk.call('winfo', 'colormapfull', self._w))
'Return the widget which is at the root coordinates ROOTX, ROOTY.'
def winfo_containing(self, rootX, rootY, displayof=0):
args = ((('winfo', 'containing') + self._displayof(displayof)) + (rootX, rootY)) name = self.tk.call(args) if (not name): return None return self._nametowidget(name)
'Return the number of bits per pixel.'
def winfo_depth(self):
return getint(self.tk.call('winfo', 'depth', self._w))
'Return true if this widget exists.'
def winfo_exists(self):
return getint(self.tk.call('winfo', 'exists', self._w))
'Return the number of pixels for the given distance NUMBER (e.g. "3c") as float.'
def winfo_fpixels(self, number):
return getdouble(self.tk.call('winfo', 'fpixels', self._w, number))
'Return geometry string for this widget in the form "widthxheight+X+Y".'
def winfo_geometry(self):
return self.tk.call('winfo', 'geometry', self._w)
'Return height of this widget.'
def winfo_height(self):
return getint(self.tk.call('winfo', 'height', self._w))
'Return identifier ID for this widget.'
def winfo_id(self):
return self.tk.getint(self.tk.call('winfo', 'id', self._w))
'Return the name of all Tcl interpreters for this display.'
def winfo_interps(self, displayof=0):
args = (('winfo', 'interps') + self._displayof(displayof)) return self.tk.splitlist(self.tk.call(args))
'Return true if this widget is mapped.'
def winfo_ismapped(self):
return getint(self.tk.call('winfo', 'ismapped', self._w))
'Return the window mananger name for this widget.'
def winfo_manager(self):
return self.tk.call('winfo', 'manager', self._w)
'Return the name of this widget.'
def winfo_name(self):
return self.tk.call('winfo', 'name', self._w)
'Return the name of the parent of this widget.'
def winfo_parent(self):
return self.tk.call('winfo', 'parent', self._w)
'Return the pathname of the widget given by ID.'
def winfo_pathname(self, id, displayof=0):
args = ((('winfo', 'pathname') + self._displayof(displayof)) + (id,)) return self.tk.call(args)
'Rounded integer value of winfo_fpixels.'
def winfo_pixels(self, number):
return getint(self.tk.call('winfo', 'pixels', self._w, number))
'Return the x coordinate of the pointer on the root window.'
def winfo_pointerx(self):
return getint(self.tk.call('winfo', 'pointerx', self._w))
'Return a tuple of x and y coordinates of the pointer on the root window.'
def winfo_pointerxy(self):
return self._getints(self.tk.call('winfo', 'pointerxy', self._w))
'Return the y coordinate of the pointer on the root window.'
def winfo_pointery(self):
return getint(self.tk.call('winfo', 'pointery', self._w))
'Return requested height of this widget.'
def winfo_reqheight(self):
return getint(self.tk.call('winfo', 'reqheight', self._w))
'Return requested width of this widget.'
def winfo_reqwidth(self):
return getint(self.tk.call('winfo', 'reqwidth', self._w))
'Return tuple of decimal values for red, green, blue for COLOR in this widget.'
def winfo_rgb(self, color):
return self._getints(self.tk.call('winfo', 'rgb', self._w, color))
'Return x coordinate of upper left corner of this widget on the root window.'
def winfo_rootx(self):
return getint(self.tk.call('winfo', 'rootx', self._w))
'Return y coordinate of upper left corner of this widget on the root window.'
def winfo_rooty(self):
return getint(self.tk.call('winfo', 'rooty', self._w))
'Return the screen name of this widget.'
def winfo_screen(self):
return self.tk.call('winfo', 'screen', self._w)
'Return the number of the cells in the colormap of the screen of this widget.'
def winfo_screencells(self):
return getint(self.tk.call('winfo', 'screencells', self._w))
'Return the number of bits per pixel of the root window of the screen of this widget.'
def winfo_screendepth(self):
return getint(self.tk.call('winfo', 'screendepth', self._w))
'Return the number of pixels of the height of the screen of this widget in pixel.'
def winfo_screenheight(self):
return getint(self.tk.call('winfo', 'screenheight', self._w))
'Return the number of pixels of the height of the screen of this widget in mm.'
def winfo_screenmmheight(self):
return getint(self.tk.call('winfo', 'screenmmheight', self._w))
'Return the number of pixels of the width of the screen of this widget in mm.'
def winfo_screenmmwidth(self):
return getint(self.tk.call('winfo', 'screenmmwidth', self._w))
'Return one of the strings directcolor, grayscale, pseudocolor, staticcolor, staticgray, or truecolor for the default colormodel of this screen.'
def winfo_screenvisual(self):
return self.tk.call('winfo', 'screenvisual', self._w)
'Return the number of pixels of the width of the screen of this widget in pixel.'
def winfo_screenwidth(self):
return getint(self.tk.call('winfo', 'screenwidth', self._w))
'Return information of the X-Server of the screen of this widget in the form "XmajorRminor vendor vendorVersion".'
def winfo_server(self):
return self.tk.call('winfo', 'server', self._w)
'Return the toplevel widget of this widget.'
def winfo_toplevel(self):
return self._nametowidget(self.tk.call('winfo', 'toplevel', self._w))
'Return true if the widget and all its higher ancestors are mapped.'
def winfo_viewable(self):
return getint(self.tk.call('winfo', 'viewable', self._w))
'Return one of the strings directcolor, grayscale, pseudocolor, staticcolor, staticgray, or truecolor for the colormodel of this widget.'
def winfo_visual(self):
return self.tk.call('winfo', 'visual', self._w)
'Return the X identifier for the visual for this widget.'
def winfo_visualid(self):
return self.tk.call('winfo', 'visualid', self._w)
'Return a list of all visuals available for the screen of this widget. Each item in the list consists of a visual name (see winfo_visual), a depth and if INCLUDEIDS=1 is given also the X identifier.'
def winfo_visualsavailable(self, includeids=0):
data = self.tk.split(self.tk.call('winfo', 'visualsavailable', self._w, ((includeids and 'includeids') or None))) if (type(data) is StringType): data = [self.tk.split(data)] return map(self.__winfo_parseitem, data)
'Internal function.'
def __winfo_parseitem(self, t):
return (t[:1] + tuple(map(self.__winfo_getint, t[1:])))
'Internal function.'
def __winfo_getint(self, x):
return int(x, 0)
'Return the height of the virtual root window associated with this widget in pixels. If there is no virtual root window return the height of the screen.'
def winfo_vrootheight(self):
return getint(self.tk.call('winfo', 'vrootheight', self._w))
'Return the width of the virtual root window associated with this widget in pixel. If there is no virtual root window return the width of the screen.'
def winfo_vrootwidth(self):
return getint(self.tk.call('winfo', 'vrootwidth', self._w))
'Return the x offset of the virtual root relative to the root window of the screen of this widget.'
def winfo_vrootx(self):
return getint(self.tk.call('winfo', 'vrootx', self._w))
'Return the y offset of the virtual root relative to the root window of the screen of this widget.'
def winfo_vrooty(self):
return getint(self.tk.call('winfo', 'vrooty', self._w))
'Return the width of this widget.'
def winfo_width(self):
return getint(self.tk.call('winfo', 'width', self._w))
'Return the x coordinate of the upper left corner of this widget in the parent.'
def winfo_x(self):
return getint(self.tk.call('winfo', 'x', self._w))
'Return the y coordinate of the upper left corner of this widget in the parent.'
def winfo_y(self):
return getint(self.tk.call('winfo', 'y', self._w))
'Enter event loop until all pending events have been processed by Tcl.'
def update(self):
self.tk.call('update')
'Enter event loop until all idle callbacks have been called. This will update the display of windows but not process events caused by the user.'
def update_idletasks(self):
self.tk.call('update', 'idletasks')
'Set or get the list of bindtags for this widget. With no argument return the list of all bindtags associated with this widget. With a list of strings as argument the bindtags are set to this list. The bindtags determine in which order events are processed (see bind).'
def bindtags(self, tagList=None):
if (tagList is None): return self.tk.splitlist(self.tk.call('bindtags', self._w)) else: self.tk.call('bindtags', self._w, tagList)
'Internal function.'
def _bind(self, what, sequence, func, add, needcleanup=1):
if (type(func) is StringType): self.tk.call((what + (sequence, func))) elif func: funcid = self._register(func, self._substitute, needcleanup) cmd = ('%sif {"[%s %s]" == "break"} break\n' % (((add and '+') or ''), funcid, self._subst_format_str)) self.tk.call((what + (sequence, cmd))) return funcid elif sequence: return self.tk.call((what + (sequence,))) else: return self.tk.splitlist(self.tk.call(what))
'Bind to this widget at event SEQUENCE a call to function FUNC. SEQUENCE is a string of concatenated event patterns. An event pattern is of the form <MODIFIER-MODIFIER-TYPE-DETAIL> where MODIFIER is one of Control, Mod2, M2, Shift, Mod3, M3, Lock, Mod4, M4, Button1, B1, Mod5, M5 Button2, B2, Meta, M, Button3, B3, Alt, Button4, B4, Double, Button5, B5 Triple, Mod1, M1. TYPE is one of Activate, Enter, Map, ButtonPress, Button, Expose, Motion, ButtonRelease FocusIn, MouseWheel, Circulate, FocusOut, Property, Colormap, Gravity Reparent, Configure, KeyPress, Key, Unmap, Deactivate, KeyRelease Visibility, Destroy, Leave and DETAIL is the button number for ButtonPress, ButtonRelease and DETAIL is the Keysym for KeyPress and KeyRelease. Examples are <Control-Button-1> for pressing Control and mouse button 1 or <Alt-A> for pressing A and the Alt key (KeyPress can be omitted). An event pattern can also be a virtual event of the form <<AString>> where AString can be arbitrary. This event can be generated by event_generate. If events are concatenated they must appear shortly after each other. FUNC will be called if the event sequence occurs with an instance of Event as argument. If the return value of FUNC is "break" no further bound function is invoked. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. Bind will return an identifier to allow deletion of the bound function with unbind without memory leak. If FUNC or SEQUENCE is omitted the bound function or list of bound events are returned.'
def bind(self, sequence=None, func=None, add=None):
return self._bind(('bind', self._w), sequence, func, add)
'Unbind for this widget for event SEQUENCE the function identified with FUNCID.'
def unbind(self, sequence, funcid=None):
self.tk.call('bind', self._w, sequence, '') if funcid: self.deletecommand(funcid)
'Bind to all widgets at an event SEQUENCE a call to function FUNC. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. See bind for the return value.'
def bind_all(self, sequence=None, func=None, add=None):
return self._bind(('bind', 'all'), sequence, func, add, 0)
'Unbind for all widgets for event SEQUENCE all functions.'
def unbind_all(self, sequence):
self.tk.call('bind', 'all', sequence, '')
'Bind to widgets with bindtag CLASSNAME at event SEQUENCE a call of function FUNC. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. See bind for the return value.'
def bind_class(self, className, sequence=None, func=None, add=None):
return self._bind(('bind', className), sequence, func, add, 0)
'Unbind for a all widgets with bindtag CLASSNAME for event SEQUENCE all functions.'
def unbind_class(self, className, sequence):
self.tk.call('bind', className, sequence, '')
'Call the mainloop of Tk.'
def mainloop(self, n=0):
self.tk.mainloop(n)
'Quit the Tcl interpreter. All widgets will be destroyed.'
def quit(self):
self.tk.quit()
'Internal function.'
def _getints(self, string):
if string: return tuple(map(getint, self.tk.splitlist(string)))
'Internal function.'
def _getdoubles(self, string):
if string: return tuple(map(getdouble, self.tk.splitlist(string)))
'Internal function.'
def _getboolean(self, string):
if string: return self.tk.getboolean(string)
'Internal function.'
def _displayof(self, displayof):
if displayof: return ('-displayof', displayof) if (displayof is None): return ('-displayof', self._w) return ()
'Internal function.'
def _options(self, cnf, kw=None):
if kw: cnf = _cnfmerge((cnf, kw)) else: cnf = _cnfmerge(cnf) res = () for (k, v) in cnf.items(): if (v is not None): if (k[(-1)] == '_'): k = k[:(-1)] if hasattr(v, '__call__'): v = self._register(v) elif isinstance(v, (tuple, list)): nv = [] for item in v: if (not isinstance(item, (basestring, int))): break elif isinstance(item, int): nv.append(('%d' % item)) else: nv.append((('{%s}' if (' ' in item) else '%s') % item)) else: v = ' '.join(nv) res = (res + (('-' + k), v)) return res
'Return the Tkinter instance of a widget identified by its Tcl name NAME.'
def nametowidget(self, name):
name = str(name).split('.') w = self if (not name[0]): w = w._root() name = name[1:] for n in name: if (not n): break w = w.children[n] return w
'Return a newly created Tcl function. If this function is called, the Python function FUNC will be executed. An optional function SUBST can be given which will be executed before FUNC.'
def _register(self, func, subst=None, needcleanup=1):
f = CallWrapper(func, subst, self).__call__ name = repr(id(f)) try: func = func.im_func except AttributeError: pass try: name = (name + func.__name__) except AttributeError: pass self.tk.createcommand(name, f) if needcleanup: if (self._tclCommands is None): self._tclCommands = [] self._tclCommands.append(name) return name
'Internal function.'
def _root(self):
w = self while w.master: w = w.master return w
'Internal function.'
def _substitute(self, *args):
if (len(args) != len(self._subst_format)): return args getboolean = self.tk.getboolean getint = int def getint_event(s): 'Tk changed behavior in 8.4.2, returning "??" rather more often.' try: return int(s) except ValueError: return s (nsign, b, f, h, k, s, t, w, x, y, A, E, K, N, W, T, X, Y, D) = args e = Event() e.serial = getint(nsign) e.num = getint_event(b) try: e.focus = getboolean(f) except TclError: pass e.height = getint_event(h) e.keycode = getint_event(k) e.state = getint_event(s) e.time = getint_event(t) e.width = getint_event(w) e.x = getint_event(x) e.y = getint_event(y) e.char = A try: e.send_event = getboolean(E) except TclError: pass e.keysym = K e.keysym_num = getint_event(N) e.type = T try: e.widget = self._nametowidget(W) except KeyError: e.widget = W e.x_root = getint_event(X) e.y_root = getint_event(Y) try: e.delta = getint(D) except ValueError: e.delta = 0 return (e,)
'Internal function.'
def _report_exception(self):
import sys (exc, val, tb) = (sys.exc_type, sys.exc_value, sys.exc_traceback) root = self._root() root.report_callback_exception(exc, val, tb)