desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Unset the variable in Tcl.'
def __del__(self):
self._tk.globalunsetvar(self._name)
'Return the name of the variable in Tcl.'
def __str__(self):
return self._name
'Set the variable to VALUE.'
def set(self, value):
return self._tk.globalsetvar(self._name, value)
'Return value of variable.'
def get(self):
return self._tk.globalgetvar(self._name)
'Define a trace callback for the variable. MODE is one of "r", "w", "u" for read, write, undefine. CALLBACK must be a function which is called when the variable is read, written or undefined. Return the name of the callback.'
def trace_variable(self, mode, callback):
cbname = self._master._register(callback) self._tk.call('trace', 'variable', self._name, mode, cbname) return cbname
'Delete the trace callback for a variable. MODE is one of "r", "w", "u" for read, write, undefine. CBNAME is the name of the callback returned from trace_variable or trace.'
def trace_vdelete(self, mode, cbname):
self._tk.call('trace', 'vdelete', self._name, mode, cbname) self._master.deletecommand(cbname)
'Return all trace callback information.'
def trace_vinfo(self):
return map(self._tk.split, self._tk.splitlist(self._tk.call('trace', 'vinfo', self._name)))
'Comparison for equality (==). Note: if the Variable\'s master matters to behavior also compare self._master == other._master'
def __eq__(self, other):
return ((self.__class__.__name__ == other.__class__.__name__) and (self._name == other._name))
'Construct a string variable. MASTER can be given as master widget. VALUE is an optional value (defaults to "") NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained.'
def __init__(self, master=None, value=None, name=None):
Variable.__init__(self, master, value, name)
'Return value of variable as string.'
def get(self):
value = self._tk.globalgetvar(self._name) if isinstance(value, basestring): return value return str(value)
'Construct an integer variable. MASTER can be given as master widget. VALUE is an optional value (defaults to 0) NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained.'
def __init__(self, master=None, value=None, name=None):
Variable.__init__(self, master, value, name)
'Set the variable to value, converting booleans to integers.'
def set(self, value):
if isinstance(value, bool): value = int(value) return Variable.set(self, value)
'Return the value of the variable as an integer.'
def get(self):
return getint(self._tk.globalgetvar(self._name))
'Construct a float variable. MASTER can be given as master widget. VALUE is an optional value (defaults to 0.0) NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained.'
def __init__(self, master=None, value=None, name=None):
Variable.__init__(self, master, value, name)
'Return the value of the variable as a float.'
def get(self):
return getdouble(self._tk.globalgetvar(self._name))
'Construct a boolean variable. MASTER can be given as master widget. VALUE is an optional value (defaults to False) NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained.'
def __init__(self, master=None, value=None, name=None):
Variable.__init__(self, master, value, name)
'Return the value of the variable as a bool.'
def get(self):
return self._tk.getboolean(self._tk.globalgetvar(self._name))
'Internal function. Delete all Tcl commands created for this widget in the Tcl interpreter.'
def destroy(self):
if (self._tclCommands is not None): for name in self._tclCommands: self.tk.deletecommand(name) self._tclCommands = None return
'Internal function. Delete the Tcl command provided in NAME.'
def deletecommand(self, name):
self.tk.deletecommand(name) try: self._tclCommands.remove(name) except ValueError: pass
'Set Tcl internal variable, whether the look and feel should adhere to Motif. A parameter of 1 means adhere to Motif (e.g. no color change if mouse passes over slider). Returns the set value.'
def tk_strictMotif(self, boolean=None):
return self.tk.getboolean(self.tk.call('set', 'tk_strictMotif', boolean))
'Change the color scheme to light brown as used in Tk 3.6 and before.'
def tk_bisque(self):
self.tk.call('tk_bisque')
'Set a new color scheme for all widget elements. A single color as argument will cause that all colors of Tk widget elements are derived from this. Alternatively several keyword parameters and its associated colors can be given. The following keywords are valid: activeBackground, foreground, selectColor, activeForegrou...
def tk_setPalette(self, *args, **kw):
self.tk.call(((('tk_setPalette',) + _flatten(args)) + _flatten(kw.items())))
'Do not use. Needed in Tk 3.6 and earlier.'
def tk_menuBar(self, *args):
pass
'Wait until the variable is modified. A parameter of type IntVar, StringVar, DoubleVar or BooleanVar must be given.'
def wait_variable(self, name='PY_VAR'):
self.tk.call('tkwait', 'variable', name)
'Wait until a WIDGET is destroyed. If no parameter is given self is used.'
def wait_window(self, window=None):
if (window is None): window = self self.tk.call('tkwait', 'window', window._w) return
'Wait until the visibility of a WIDGET changes (e.g. it appears). If no parameter is given self is used.'
def wait_visibility(self, window=None):
if (window is None): window = self self.tk.call('tkwait', 'visibility', window._w) return
'Set Tcl variable NAME to VALUE.'
def setvar(self, name='PY_VAR', value='1'):
self.tk.setvar(name, value)
'Return value of Tcl variable NAME.'
def getvar(self, name='PY_VAR'):
return self.tk.getvar(name)
'Return a boolean value for Tcl boolean values true and false given as parameter.'
def getboolean(self, s):
return self.tk.getboolean(s)
'Direct input focus to this widget. If the application currently does not have the focus this widget will get the focus if the application gets the focus through the window manager.'
def focus_set(self):
self.tk.call('focus', self._w)
'Direct input focus to this widget even if the application does not have the focus. Use with caution!'
def focus_force(self):
self.tk.call('focus', '-force', self._w)
'Return the widget which has currently the focus in the application. Use focus_displayof to allow working with several displays. Return None if application does not have the focus.'
def focus_get(self):
name = self.tk.call('focus') if ((name == 'none') or (not name)): return None else: return self._nametowidget(name)
'Return the widget which has currently the focus on the display where this widget is located. Return None if the application does not have the focus.'
def focus_displayof(self):
name = self.tk.call('focus', '-displayof', self._w) if ((name == 'none') or (not name)): return None else: return self._nametowidget(name)
'Return the widget which would have the focus if top level for this widget gets the focus from the window manager.'
def focus_lastfor(self):
name = self.tk.call('focus', '-lastfor', self._w) if ((name == 'none') or (not name)): return None else: return self._nametowidget(name)
'The widget under mouse will get automatically focus. Can not be disabled easily.'
def tk_focusFollowsMouse(self):
self.tk.call('tk_focusFollowsMouse')
'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 else: 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 else: 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) ...
'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: sele...
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 else: 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...
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 else: 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 else: 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))