desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Return information about the packing options for this widget.'
def pack_info(self):
words = self.tk.splitlist(self.tk.call('pack', 'info', self._w)) dict = {} for i in range(0, len(words), 2): key = words[i][1:] value = words[(i + 1)] if (value[:1] == '.'): value = self._nametowidget(value) dict[key] = value return dict
'Place a widget in the parent widget. Use as options: in=master - master relative to which the widget is placed in_=master - see \'in\' option description x=amount - locate anchor of this widget at position x of master y=amount - locate anchor of this widget at position y of master relx=amount - locate anchor of this w...
def place_configure(self, cnf={}, **kw):
self.tk.call((('place', 'configure', self._w) + self._options(cnf, kw)))
'Unmap this widget.'
def place_forget(self):
self.tk.call('place', 'forget', self._w)
'Return information about the placing options for this widget.'
def place_info(self):
words = self.tk.splitlist(self.tk.call('place', 'info', self._w)) dict = {} for i in range(0, len(words), 2): key = words[i][1:] value = words[(i + 1)] if (value[:1] == '.'): value = self._nametowidget(value) dict[key] = value return dict
'Position a widget in the parent widget in a grid. Use as options: column=number - use cell identified with given column (starting with 0) columnspan=number - this widget will span several columns in=master - use master to contain this widget in_=master - see \'in\' option description ipadx=amount - add internal paddin...
def grid_configure(self, cnf={}, **kw):
self.tk.call((('grid', 'configure', self._w) + self._options(cnf, kw)))
'Unmap this widget.'
def grid_forget(self):
self.tk.call('grid', 'forget', self._w)
'Unmap this widget but remember the grid options.'
def grid_remove(self):
self.tk.call('grid', 'remove', self._w)
'Return information about the options for positioning this widget in a grid.'
def grid_info(self):
words = self.tk.splitlist(self.tk.call('grid', 'info', self._w)) dict = {} for i in range(0, len(words), 2): key = words[i][1:] value = words[(i + 1)] if (value[:1] == '.'): value = self._nametowidget(value) dict[key] = value return dict
'Internal function. Sets up information about children.'
def _setup(self, master, cnf):
global _default_root if _support_default_root: if (not master): if (not _default_root): _default_root = Tk() master = _default_root self.master = master self.tk = master.tk name = None if ('name' in cnf): name = cnf['name'] del cnf[...
'Construct a widget with the parent widget MASTER, a name WIDGETNAME and appropriate options.'
def __init__(self, master, widgetName, cnf={}, kw={}, extra=()):
if kw: cnf = _cnfmerge((cnf, kw)) self.widgetName = widgetName BaseWidget._setup(self, master, cnf) if (self._tclCommands is None): self._tclCommands = [] classes = [] for k in cnf.keys(): if (type(k) is ClassType): classes.append((k, cnf[k])) del ...
'Destroy this and all descendants widgets.'
def destroy(self):
for c in self.children.values(): c.destroy() self.tk.call('destroy', self._w) if (self._name in self.master.children): del self.master.children[self._name] Misc.destroy(self)
'Construct a toplevel widget with the parent MASTER. Valid resource names: background, bd, bg, borderwidth, class, colormap, container, cursor, height, highlightbackground, highlightcolor, highlightthickness, menu, relief, screen, takefocus, use, visual, width.'
def __init__(self, master=None, cnf={}, **kw):
if kw: cnf = _cnfmerge((cnf, kw)) extra = () for wmkey in ['screen', 'class_', 'class', 'visual', 'colormap']: if (wmkey in cnf): val = cnf[wmkey] if (wmkey[(-1)] == '_'): opt = ('-' + wmkey[:(-1)]) else: opt = ('-' + wmkey)...
'Construct a button widget with the parent MASTER. STANDARD OPTIONS activebackground, activeforeground, anchor, background, bitmap, borderwidth, cursor, disabledforeground, font, foreground highlightbackground, highlightcolor, highlightthickness, image, justify, padx, pady, relief, repeatdelay, repeatinterval, takefocu...
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, 'button', cnf, kw)
'Flash the button. This is accomplished by redisplaying the button several times, alternating between active and normal colors. At the end of the flash the button is left in the same normal/active state as when the command was invoked. This command is ignored if the button\'s state is disabled.'
def flash(self):
self.tk.call(self._w, 'flash')
'Invoke the command associated with the button. The return value is the return value from the command, or an empty string if there is no command associated with the button. This command is ignored if the button\'s state is disabled.'
def invoke(self):
return self.tk.call(self._w, 'invoke')
'Construct a canvas widget with the parent MASTER. Valid resource names: background, bd, bg, borderwidth, closeenough, confine, cursor, height, highlightbackground, highlightcolor, highlightthickness, insertbackground, insertborderwidth, insertofftime, insertontime, insertwidth, offset, relief, scrollregion, selectback...
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, 'canvas', cnf, kw)
'Internal function.'
def addtag(self, *args):
self.tk.call(((self._w, 'addtag') + args))
'Add tag NEWTAG to all items above TAGORID.'
def addtag_above(self, newtag, tagOrId):
self.addtag(newtag, 'above', tagOrId)
'Add tag NEWTAG to all items.'
def addtag_all(self, newtag):
self.addtag(newtag, 'all')
'Add tag NEWTAG to all items below TAGORID.'
def addtag_below(self, newtag, tagOrId):
self.addtag(newtag, 'below', tagOrId)
'Add tag NEWTAG to item which is closest to pixel at X, Y. If several match take the top-most. All items closer than HALO are considered overlapping (all are closests). If START is specified the next below this tag is taken.'
def addtag_closest(self, newtag, x, y, halo=None, start=None):
self.addtag(newtag, 'closest', x, y, halo, start)
'Add tag NEWTAG to all items in the rectangle defined by X1,Y1,X2,Y2.'
def addtag_enclosed(self, newtag, x1, y1, x2, y2):
self.addtag(newtag, 'enclosed', x1, y1, x2, y2)
'Add tag NEWTAG to all items which overlap the rectangle defined by X1,Y1,X2,Y2.'
def addtag_overlapping(self, newtag, x1, y1, x2, y2):
self.addtag(newtag, 'overlapping', x1, y1, x2, y2)
'Add tag NEWTAG to all items with TAGORID.'
def addtag_withtag(self, newtag, tagOrId):
self.addtag(newtag, 'withtag', tagOrId)
'Return a tuple of X1,Y1,X2,Y2 coordinates for a rectangle which encloses all items with tags specified as arguments.'
def bbox(self, *args):
return (self._getints(self.tk.call(((self._w, 'bbox') + args))) or None)
'Unbind for all items with TAGORID for event SEQUENCE the function identified with FUNCID.'
def tag_unbind(self, tagOrId, sequence, funcid=None):
self.tk.call(self._w, 'bind', tagOrId, sequence, '') if funcid: self.deletecommand(funcid)
'Bind to all items with TAGORID at 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 tag_bind(self, tagOrId, sequence=None, func=None, add=None):
return self._bind((self._w, 'bind', tagOrId), sequence, func, add)
'Return the canvas x coordinate of pixel position SCREENX rounded to nearest multiple of GRIDSPACING units.'
def canvasx(self, screenx, gridspacing=None):
return getdouble(self.tk.call(self._w, 'canvasx', screenx, gridspacing))
'Return the canvas y coordinate of pixel position SCREENY rounded to nearest multiple of GRIDSPACING units.'
def canvasy(self, screeny, gridspacing=None):
return getdouble(self.tk.call(self._w, 'canvasy', screeny, gridspacing))
'Return a list of coordinates for the item given in ARGS.'
def coords(self, *args):
return map(getdouble, self.tk.splitlist(self.tk.call(((self._w, 'coords') + args))))
'Internal function.'
def _create(self, itemType, args, kw):
args = _flatten(args) cnf = args[(-1)] if (type(cnf) in (DictionaryType, TupleType)): args = args[:(-1)] else: cnf = {} return getint(self.tk.call(self._w, 'create', itemType, *(args + self._options(cnf, kw))))
'Create arc shaped region with coordinates x1,y1,x2,y2.'
def create_arc(self, *args, **kw):
return self._create('arc', args, kw)
'Create bitmap with coordinates x1,y1.'
def create_bitmap(self, *args, **kw):
return self._create('bitmap', args, kw)
'Create image item with coordinates x1,y1.'
def create_image(self, *args, **kw):
return self._create('image', args, kw)
'Create line with coordinates x1,y1,...,xn,yn.'
def create_line(self, *args, **kw):
return self._create('line', args, kw)
'Create oval with coordinates x1,y1,x2,y2.'
def create_oval(self, *args, **kw):
return self._create('oval', args, kw)
'Create polygon with coordinates x1,y1,...,xn,yn.'
def create_polygon(self, *args, **kw):
return self._create('polygon', args, kw)
'Create rectangle with coordinates x1,y1,x2,y2.'
def create_rectangle(self, *args, **kw):
return self._create('rectangle', args, kw)
'Create text with coordinates x1,y1.'
def create_text(self, *args, **kw):
return self._create('text', args, kw)
'Create window with coordinates x1,y1,x2,y2.'
def create_window(self, *args, **kw):
return self._create('window', args, kw)
'Delete characters of text items identified by tag or id in ARGS (possibly several times) from FIRST to LAST character (including).'
def dchars(self, *args):
self.tk.call(((self._w, 'dchars') + args))
'Delete items identified by all tag or ids contained in ARGS.'
def delete(self, *args):
self.tk.call(((self._w, 'delete') + args))
'Delete tag or id given as last arguments in ARGS from items identified by first argument in ARGS.'
def dtag(self, *args):
self.tk.call(((self._w, 'dtag') + args))
'Internal function.'
def find(self, *args):
return (self._getints(self.tk.call(((self._w, 'find') + args))) or ())
'Return items above TAGORID.'
def find_above(self, tagOrId):
return self.find('above', tagOrId)
'Return all items.'
def find_all(self):
return self.find('all')
'Return all items below TAGORID.'
def find_below(self, tagOrId):
return self.find('below', tagOrId)
'Return item which is closest to pixel at X, Y. If several match take the top-most. All items closer than HALO are considered overlapping (all are closests). If START is specified the next below this tag is taken.'
def find_closest(self, x, y, halo=None, start=None):
return self.find('closest', x, y, halo, start)
'Return all items in rectangle defined by X1,Y1,X2,Y2.'
def find_enclosed(self, x1, y1, x2, y2):
return self.find('enclosed', x1, y1, x2, y2)
'Return all items which overlap the rectangle defined by X1,Y1,X2,Y2.'
def find_overlapping(self, x1, y1, x2, y2):
return self.find('overlapping', x1, y1, x2, y2)
'Return all items with TAGORID.'
def find_withtag(self, tagOrId):
return self.find('withtag', tagOrId)
'Set focus to the first item specified in ARGS.'
def focus(self, *args):
return self.tk.call(((self._w, 'focus') + args))
'Return tags associated with the first item specified in ARGS.'
def gettags(self, *args):
return self.tk.splitlist(self.tk.call(((self._w, 'gettags') + args)))
'Set cursor at position POS in the item identified by TAGORID. In ARGS TAGORID must be first.'
def icursor(self, *args):
self.tk.call(((self._w, 'icursor') + args))
'Return position of cursor as integer in item specified in ARGS.'
def index(self, *args):
return getint(self.tk.call(((self._w, 'index') + args)))
'Insert TEXT in item TAGORID at position POS. ARGS must be TAGORID POS TEXT.'
def insert(self, *args):
self.tk.call(((self._w, 'insert') + args))
'Return the resource value for an OPTION for item TAGORID.'
def itemcget(self, tagOrId, option):
return self.tk.call(((self._w, 'itemcget') + (tagOrId, ('-' + option))))
'Configure resources of an item TAGORID. The values for resources are specified as keyword arguments. To get an overview about the allowed keyword arguments call the method without arguments.'
def itemconfigure(self, tagOrId, cnf=None, **kw):
return self._configure(('itemconfigure', tagOrId), cnf, kw)
'Lower an item TAGORID given in ARGS (optional below another item).'
def tag_lower(self, *args):
self.tk.call(((self._w, 'lower') + args))
'Move an item TAGORID given in ARGS.'
def move(self, *args):
self.tk.call(((self._w, 'move') + args))
'Print the contents of the canvas to a postscript file. Valid options: colormap, colormode, file, fontmap, height, pageanchor, pageheight, pagewidth, pagex, pagey, rotate, witdh, x, y.'
def postscript(self, cnf={}, **kw):
return self.tk.call(((self._w, 'postscript') + self._options(cnf, kw)))
'Raise an item TAGORID given in ARGS (optional above another item).'
def tag_raise(self, *args):
self.tk.call(((self._w, 'raise') + args))
'Scale item TAGORID with XORIGIN, YORIGIN, XSCALE, YSCALE.'
def scale(self, *args):
self.tk.call(((self._w, 'scale') + args))
'Remember the current X, Y coordinates.'
def scan_mark(self, x, y):
self.tk.call(self._w, 'scan', 'mark', x, y)
'Adjust the view of the canvas to GAIN times the difference between X and Y and the coordinates given in scan_mark.'
def scan_dragto(self, x, y, gain=10):
self.tk.call(self._w, 'scan', 'dragto', x, y, gain)
'Adjust the end of the selection near the cursor of an item TAGORID to index.'
def select_adjust(self, tagOrId, index):
self.tk.call(self._w, 'select', 'adjust', tagOrId, index)
'Clear the selection if it is in this widget.'
def select_clear(self):
self.tk.call(self._w, 'select', 'clear')
'Set the fixed end of a selection in item TAGORID to INDEX.'
def select_from(self, tagOrId, index):
self.tk.call(self._w, 'select', 'from', tagOrId, index)
'Return the item which has the selection.'
def select_item(self):
return (self.tk.call(self._w, 'select', 'item') or None)
'Set the variable end of a selection in item TAGORID to INDEX.'
def select_to(self, tagOrId, index):
self.tk.call(self._w, 'select', 'to', tagOrId, index)
'Return the type of the item TAGORID.'
def type(self, tagOrId):
return (self.tk.call(self._w, 'type', tagOrId) or None)
'Construct a checkbutton widget with the parent MASTER. Valid resource names: activebackground, activeforeground, anchor, background, bd, bg, bitmap, borderwidth, command, cursor, disabledforeground, fg, font, foreground, height, highlightbackground, highlightcolor, highlightthickness, image, indicatoron, justify, offv...
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, 'checkbutton', cnf, kw)
'Put the button in off-state.'
def deselect(self):
self.tk.call(self._w, 'deselect')
'Flash the button.'
def flash(self):
self.tk.call(self._w, 'flash')
'Toggle the button and invoke a command if given as resource.'
def invoke(self):
return self.tk.call(self._w, 'invoke')
'Put the button in on-state.'
def select(self):
self.tk.call(self._w, 'select')
'Toggle the button.'
def toggle(self):
self.tk.call(self._w, 'toggle')
'Construct an entry widget with the parent MASTER. Valid resource names: background, bd, bg, borderwidth, cursor, exportselection, fg, font, foreground, highlightbackground, highlightcolor, highlightthickness, insertbackground, insertborderwidth, insertofftime, insertontime, insertwidth, invalidcommand, invcmd, justify...
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, 'entry', cnf, kw)
'Delete text from FIRST to LAST (not included).'
def delete(self, first, last=None):
self.tk.call(self._w, 'delete', first, last)
'Return the text.'
def get(self):
return self.tk.call(self._w, 'get')
'Insert cursor at INDEX.'
def icursor(self, index):
self.tk.call(self._w, 'icursor', index)
'Return position of cursor.'
def index(self, index):
return getint(self.tk.call(self._w, 'index', index))
'Insert STRING at INDEX.'
def insert(self, index, string):
self.tk.call(self._w, 'insert', index, string)
'Remember the current X, Y coordinates.'
def scan_mark(self, x):
self.tk.call(self._w, 'scan', 'mark', x)
'Adjust the view of the canvas to 10 times the difference between X and Y and the coordinates given in scan_mark.'
def scan_dragto(self, x):
self.tk.call(self._w, 'scan', 'dragto', x)
'Adjust the end of the selection near the cursor to INDEX.'
def selection_adjust(self, index):
self.tk.call(self._w, 'selection', 'adjust', index)
'Clear the selection if it is in this widget.'
def selection_clear(self):
self.tk.call(self._w, 'selection', 'clear')
'Set the fixed end of a selection to INDEX.'
def selection_from(self, index):
self.tk.call(self._w, 'selection', 'from', index)
'Return True if there are characters selected in the entry, False otherwise.'
def selection_present(self):
return self.tk.getboolean(self.tk.call(self._w, 'selection', 'present'))
'Set the selection from START to END (not included).'
def selection_range(self, start, end):
self.tk.call(self._w, 'selection', 'range', start, end)
'Set the variable end of a selection to INDEX.'
def selection_to(self, index):
self.tk.call(self._w, 'selection', 'to', index)
'Construct a frame widget with the parent MASTER. Valid resource names: background, bd, bg, borderwidth, class, colormap, container, cursor, height, highlightbackground, highlightcolor, highlightthickness, relief, takefocus, visual, width.'
def __init__(self, master=None, cnf={}, **kw):
cnf = _cnfmerge((cnf, kw)) extra = () if ('class_' in cnf): extra = ('-class', cnf['class_']) del cnf['class_'] elif ('class' in cnf): extra = ('-class', cnf['class']) del cnf['class'] Widget.__init__(self, master, 'frame', cnf, {}, extra)
'Construct a label widget with the parent MASTER. STANDARD OPTIONS activebackground, activeforeground, anchor, background, bitmap, borderwidth, cursor, disabledforeground, font, foreground, highlightbackground, highlightcolor, highlightthickness, image, justify, padx, pady, relief, takefocus, text, textvariable, underl...
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, 'label', cnf, kw)
'Construct a listbox widget with the parent MASTER. Valid resource names: background, bd, bg, borderwidth, cursor, exportselection, fg, font, foreground, height, highlightbackground, highlightcolor, highlightthickness, relief, selectbackground, selectborderwidth, selectforeground, selectmode, setgrid, takefocus, width,...
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, 'listbox', cnf, kw)
'Activate item identified by INDEX.'
def activate(self, index):
self.tk.call(self._w, 'activate', index)
'Return a tuple of X1,Y1,X2,Y2 coordinates for a rectangle which encloses the item identified by index in ARGS.'
def bbox(self, *args):
return (self._getints(self.tk.call(((self._w, 'bbox') + args))) or None)
'Return list of indices of currently selected item.'
def curselection(self):
return self.tk.splitlist(self.tk.call(self._w, 'curselection'))
'Delete items from FIRST to LAST (not included).'
def delete(self, first, last=None):
self.tk.call(self._w, 'delete', first, last)
'Get list of items from FIRST to LAST (not included).'
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)
'Return index of item identified with INDEX.'
def index(self, index):
i = self.tk.call(self._w, 'index', index) if (i == 'none'): return None else: return getint(i)