desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Temporarily sets the current theme to themename, apply specified
settings and then restore the previous theme.
Each key in settings is a style and each value may contain the
keys \'configure\', \'map\', \'layout\' and \'element create\' and they
are expected to have the same format as specified by the methods
configur... | def theme_settings(self, themename, settings):
| script = _script_from_settings(settings)
self.tk.call(self._name, 'theme', 'settings', themename, script)
|
'Returns a list of all known themes.'
| def theme_names(self):
| return self.tk.call(self._name, 'theme', 'names')
|
'If themename is None, returns the theme in use, otherwise, set
the current theme to themename, refreshes all widgets and emits
a <<ThemeChanged>> event.'
| def theme_use(self, themename=None):
| if (themename is None):
return self.tk.eval('return $ttk::currentTheme')
else:
self.tk.call('ttk::setTheme', themename)
return
|
'Constructs a Ttk Widget with the parent master.
STANDARD OPTIONS
class, cursor, takefocus, style
SCROLLABLE WIDGET OPTIONS
xscrollcommand, yscrollcommand
LABEL WIDGET OPTIONS
text, textvariable, underline, image, compound, width
WIDGET STATES
active, disabled, focus, pressed, selected, background,
readonly, alternate,... | def __init__(self, master, widgetname, kw=None):
| master = setup_master(master)
if (not getattr(master, '_tile_loaded', False)):
_load_tile(master)
Tkinter.Widget.__init__(self, master, widgetname, kw=kw)
|
'Returns the name of the element at position x, y, or the empty
string if the point does not lie within any element.
x and y are pixel coordinates relative to the widget.'
| def identify(self, x, y):
| return self.tk.call(self._w, 'identify', x, y)
|
'Test the widget\'s state.
If callback is not specified, returns True if the widget state
matches statespec and False otherwise. If callback is specified,
then it will be invoked with *args, **kw if the widget state
matches statespec. statespec is expected to be a sequence.'
| def instate(self, statespec, callback=None, *args, **kw):
| ret = self.tk.call(self._w, 'instate', ' '.join(statespec))
if (ret and callback):
return callback(*args, **kw)
return bool(ret)
|
'Modify or inquire widget state.
Widget state is returned if statespec is None, otherwise it is
set according to the statespec flags and then a new state spec
is returned indicating which flags were changed. statespec is
expected to be a sequence.'
| def state(self, statespec=None):
| if (statespec is not None):
statespec = ' '.join(statespec)
return self.tk.splitlist(str(self.tk.call(self._w, 'state', statespec)))
|
'Construct a Ttk Button widget with the parent master.
STANDARD OPTIONS
class, compound, cursor, image, state, style, takefocus,
text, textvariable, underline, width
WIDGET-SPECIFIC OPTIONS
command, default, width'
| def __init__(self, master=None, **kw):
| Widget.__init__(self, master, 'ttk::button', kw)
|
'Invokes the command associated with the button.'
| def invoke(self):
| return self.tk.call(self._w, 'invoke')
|
'Construct a Ttk Checkbutton widget with the parent master.
STANDARD OPTIONS
class, compound, cursor, image, state, style, takefocus,
text, textvariable, underline, width
WIDGET-SPECIFIC OPTIONS
command, offvalue, onvalue, variable'
| def __init__(self, master=None, **kw):
| Widget.__init__(self, master, 'ttk::checkbutton', kw)
|
'Toggles between the selected and deselected states and
invokes the associated command. If the widget is currently
selected, sets the option variable to the offvalue option
and deselects the widget; otherwise, sets the option variable
to the option onvalue.
Returns the result of the associated command.'
| def invoke(self):
| return self.tk.call(self._w, 'invoke')
|
'Constructs a Ttk Entry widget with the parent master.
STANDARD OPTIONS
class, cursor, style, takefocus, xscrollcommand
WIDGET-SPECIFIC OPTIONS
exportselection, invalidcommand, justify, show, state,
textvariable, validate, validatecommand, width
VALIDATION MODES
none, key, focus, focusin, focusout, all'
| def __init__(self, master=None, widget=None, **kw):
| Widget.__init__(self, master, (widget or 'ttk::entry'), kw)
|
'Return a tuple of (x, y, width, height) which describes the
bounding box of the character given by index.'
| def bbox(self, index):
| return self.tk.call(self._w, 'bbox', index)
|
'Returns the name of the element at position x, y, or the
empty string if the coordinates are outside the window.'
| def identify(self, x, y):
| return self.tk.call(self._w, 'identify', x, y)
|
'Force revalidation, independent of the conditions specified
by the validate option. Returns False if validation fails, True
if it succeeds. Sets or clears the invalid state accordingly.'
| def validate(self):
| return bool(self.tk.call(self._w, 'validate'))
|
'Construct a Ttk Combobox widget with the parent master.
STANDARD OPTIONS
class, cursor, style, takefocus
WIDGET-SPECIFIC OPTIONS
exportselection, justify, height, postcommand, state,
textvariable, values, width'
| def __init__(self, master=None, **kw):
| if ('values' in kw):
kw['values'] = _format_optdict({'v': kw['values']})[1]
Entry.__init__(self, master, 'ttk::combobox', **kw)
|
'Custom Combobox configure, created to properly format the values
option.'
| def configure(self, cnf=None, **kw):
| if ('values' in kw):
kw['values'] = _format_optdict({'v': kw['values']})[1]
return Entry.configure(self, cnf, **kw)
|
'If newindex is supplied, sets the combobox value to the
element at position newindex in the list of values. Otherwise,
returns the index of the current value in the list of values
or -1 if the current value does not appear in the list.'
| def current(self, newindex=None):
| return self.tk.call(self._w, 'current', newindex)
|
'Sets the value of the combobox to value.'
| def set(self, value):
| self.tk.call(self._w, 'set', value)
|
'Construct a Ttk Frame with parent master.
STANDARD OPTIONS
class, cursor, style, takefocus
WIDGET-SPECIFIC OPTIONS
borderwidth, relief, padding, width, height'
| def __init__(self, master=None, **kw):
| Widget.__init__(self, master, 'ttk::frame', kw)
|
'Construct a Ttk Label with parent master.
STANDARD OPTIONS
class, compound, cursor, image, style, takefocus, text,
textvariable, underline, width
WIDGET-SPECIFIC OPTIONS
anchor, background, font, foreground, justify, padding,
relief, text, wraplength'
| def __init__(self, master=None, **kw):
| Widget.__init__(self, master, 'ttk::label', kw)
|
'Construct a Ttk Labelframe with parent master.
STANDARD OPTIONS
class, cursor, style, takefocus
WIDGET-SPECIFIC OPTIONS
labelanchor, text, underline, padding, labelwidget, width,
height'
| def __init__(self, master=None, **kw):
| Widget.__init__(self, master, 'ttk::labelframe', kw)
|
'Construct a Ttk Menubutton with parent master.
STANDARD OPTIONS
class, compound, cursor, image, state, style, takefocus,
text, textvariable, underline, width
WIDGET-SPECIFIC OPTIONS
direction, menu'
| def __init__(self, master=None, **kw):
| Widget.__init__(self, master, 'ttk::menubutton', kw)
|
'Construct a Ttk Notebook with parent master.
STANDARD OPTIONS
class, cursor, style, takefocus
WIDGET-SPECIFIC OPTIONS
height, padding, width
TAB OPTIONS
state, sticky, padding, text, image, compound, underline
TAB IDENTIFIERS (tab_id)
The tab_id argument found in several methods may take any of
the following forms:
* ... | def __init__(self, master=None, **kw):
| Widget.__init__(self, master, 'ttk::notebook', kw)
|
'Adds a new tab to the notebook.
If window is currently managed by the notebook but hidden, it is
restored to its previous position.'
| def add(self, child, **kw):
| self.tk.call(self._w, 'add', child, *_format_optdict(kw))
|
'Removes the tab specified by tab_id, unmaps and unmanages the
associated window.'
| def forget(self, tab_id):
| self.tk.call(self._w, 'forget', tab_id)
|
'Hides the tab specified by tab_id.
The tab will not be displayed, but the associated window remains
managed by the notebook and its configuration remembered. Hidden
tabs may be restored with the add command.'
| def hide(self, tab_id):
| self.tk.call(self._w, 'hide', tab_id)
|
'Returns the name of the tab element at position x, y, or the
empty string if none.'
| def identify(self, x, y):
| return self.tk.call(self._w, 'identify', x, y)
|
'Returns the numeric index of the tab specified by tab_id, or
the total number of tabs if tab_id is the string "end".'
| def index(self, tab_id):
| return self.tk.call(self._w, 'index', tab_id)
|
'Inserts a pane at the specified position.
pos is either the string end, an integer index, or the name of
a managed child. If child is already managed by the notebook,
moves it to the specified position.'
| def insert(self, pos, child, **kw):
| self.tk.call(self._w, 'insert', pos, child, *_format_optdict(kw))
|
'Selects the specified tab.
The associated child window will be displayed, and the
previously-selected window (if different) is unmapped. If tab_id
is omitted, returns the widget name of the currently selected
pane.'
| def select(self, tab_id=None):
| return self.tk.call(self._w, 'select', tab_id)
|
'Query or modify the options of the specific tab_id.
If kw is not given, returns a dict of the tab option values. If option
is specified, returns the value of that option. Otherwise, sets the
options to the corresponding values.'
| def tab(self, tab_id, option=None, **kw):
| if (option is not None):
kw[option] = None
return _val_or_dict(kw, self.tk.call, self._w, 'tab', tab_id)
|
'Returns a list of windows managed by the notebook.'
| def tabs(self):
| return (self.tk.call(self._w, 'tabs') or ())
|
'Enable keyboard traversal for a toplevel window containing
this notebook.
This will extend the bindings for the toplevel window containing
this notebook as follows:
Control-Tab: selects the tab following the currently selected
one
Shift-Control-Tab: selects the tab preceding the currently
selected one
Alt-K: where K i... | def enable_traversal(self):
| self.tk.call('ttk::notebook::enableTraversal', self._w)
|
'Construct a Ttk Panedwindow with parent master.
STANDARD OPTIONS
class, cursor, style, takefocus
WIDGET-SPECIFIC OPTIONS
orient, width, height
PANE OPTIONS
weight'
| def __init__(self, master=None, **kw):
| Widget.__init__(self, master, 'ttk::panedwindow', kw)
|
'Inserts a pane at the specified positions.
pos is either the string end, and integer index, or the name
of a child. If child is already managed by the paned window,
moves it to the specified position.'
| def insert(self, pos, child, **kw):
| self.tk.call(self._w, 'insert', pos, child, *_format_optdict(kw))
|
'Query or modify the options of the specified pane.
pane is either an integer index or the name of a managed subwindow.
If kw is not given, returns a dict of the pane option values. If
option is specified then the value for that option is returned.
Otherwise, sets the options to the corresponding values.'
| def pane(self, pane, option=None, **kw):
| if (option is not None):
kw[option] = None
return _val_or_dict(kw, self.tk.call, self._w, 'pane', pane)
|
'If newpos is specified, sets the position of sash number index.
May adjust the positions of adjacent sashes to ensure that
positions are monotonically increasing. Sash positions are further
constrained to be between 0 and the total size of the widget.
Returns the new position of sash number index.'
| def sashpos(self, index, newpos=None):
| return self.tk.call(self._w, 'sashpos', index, newpos)
|
'Construct a Ttk Progressbar with parent master.
STANDARD OPTIONS
class, cursor, style, takefocus
WIDGET-SPECIFIC OPTIONS
orient, length, mode, maximum, value, variable, phase'
| def __init__(self, master=None, **kw):
| Widget.__init__(self, master, 'ttk::progressbar', kw)
|
'Begin autoincrement mode: schedules a recurring timer event
that calls method step every interval milliseconds.
interval defaults to 50 milliseconds (20 steps/second) if ommited.'
| def start(self, interval=None):
| self.tk.call(self._w, 'start', interval)
|
'Increments the value option by amount.
amount defaults to 1.0 if omitted.'
| def step(self, amount=None):
| self.tk.call(self._w, 'step', amount)
|
'Stop autoincrement mode: cancels any recurring timer event
initiated by start.'
| def stop(self):
| self.tk.call(self._w, 'stop')
|
'Construct a Ttk Radiobutton with parent master.
STANDARD OPTIONS
class, compound, cursor, image, state, style, takefocus,
text, textvariable, underline, width
WIDGET-SPECIFIC OPTIONS
command, value, variable'
| def __init__(self, master=None, **kw):
| Widget.__init__(self, master, 'ttk::radiobutton', kw)
|
'Sets the option variable to the option value, selects the
widget, and invokes the associated command.
Returns the result of the command, or an empty string if
no command is specified.'
| def invoke(self):
| return self.tk.call(self._w, 'invoke')
|
'Construct a Ttk Scale with parent master.
STANDARD OPTIONS
class, cursor, style, takefocus
WIDGET-SPECIFIC OPTIONS
command, from, length, orient, to, value, variable'
| def __init__(self, master=None, **kw):
| Widget.__init__(self, master, 'ttk::scale', kw)
|
'Modify or query scale options.
Setting a value for any of the "from", "from_" or "to" options
generates a <<RangeChanged>> event.'
| def configure(self, cnf=None, **kw):
| if cnf:
kw.update(cnf)
Widget.configure(self, **kw)
if any([('from' in kw), ('from_' in kw), ('to' in kw)]):
self.event_generate('<<RangeChanged>>')
|
'Get the current value of the value option, or the value
corresponding to the coordinates x, y if they are specified.
x and y are pixel coordinates relative to the scale widget
origin.'
| def get(self, x=None, y=None):
| return self.tk.call(self._w, 'get', x, y)
|
'Construct a Ttk Scrollbar with parent master.
STANDARD OPTIONS
class, cursor, style, takefocus
WIDGET-SPECIFIC OPTIONS
command, orient'
| def __init__(self, master=None, **kw):
| Widget.__init__(self, master, 'ttk::scrollbar', kw)
|
'Construct a Ttk Separator with parent master.
STANDARD OPTIONS
class, cursor, style, takefocus
WIDGET-SPECIFIC OPTIONS
orient'
| def __init__(self, master=None, **kw):
| Widget.__init__(self, master, 'ttk::separator', kw)
|
'Construct a Ttk Sizegrip with parent master.
STANDARD OPTIONS
class, cursor, state, style, takefocus'
| def __init__(self, master=None, **kw):
| Widget.__init__(self, master, 'ttk::sizegrip', kw)
|
'Construct a Ttk Treeview with parent master.
STANDARD OPTIONS
class, cursor, style, takefocus, xscrollcommand,
yscrollcommand
WIDGET-SPECIFIC OPTIONS
columns, displaycolumns, height, padding, selectmode, show
ITEM OPTIONS
text, image, values, open, tags
TAG OPTIONS
foreground, background, font, image'
| def __init__(self, master=None, **kw):
| Widget.__init__(self, master, 'ttk::treeview', kw)
|
'Returns the bounding box (relative to the treeview widget\'s
window) of the specified item in the form x y width height.
If column is specified, returns the bounding box of that cell.
If the item is not visible (i.e., if it is a descendant of a
closed item or is scrolled offscreen), returns an empty string.'
| def bbox(self, item, column=None):
| return self.tk.call(self._w, 'bbox', item, column)
|
'Returns a tuple of children belonging to item.
If item is not specified, returns root children.'
| def get_children(self, item=None):
| return (self.tk.call(self._w, 'children', (item or '')) or ())
|
'Replaces item\'s child with newchildren.
Children present in item that are not present in newchildren
are detached from tree. No items in newchildren may be an
ancestor of item.'
| def set_children(self, item, *newchildren):
| self.tk.call(self._w, 'children', item, newchildren)
|
'Query or modify the options for the specified column.
If kw is not given, returns a dict of the column option values. If
option is specified then the value for that option is returned.
Otherwise, sets the options to the corresponding values.'
| def column(self, column, option=None, **kw):
| if (option is not None):
kw[option] = None
return _val_or_dict(kw, self.tk.call, self._w, 'column', column)
|
'Delete all specified items and all their descendants. The root
item may not be deleted.'
| def delete(self, *items):
| self.tk.call(self._w, 'delete', items)
|
'Unlinks all of the specified items from the tree.
The items and all of their descendants are still present, and may
be reinserted at another point in the tree, but will not be
displayed. The root item may not be detached.'
| def detach(self, *items):
| self.tk.call(self._w, 'detach', items)
|
'Returns True if the specified item is present in the three,
False otherwise.'
| def exists(self, item):
| return bool(self.tk.call(self._w, 'exists', item))
|
'If item is specified, sets the focus item to item. Otherwise,
returns the current focus item, or \'\' if there is none.'
| def focus(self, item=None):
| return self.tk.call(self._w, 'focus', item)
|
'Query or modify the heading options for the specified column.
If kw is not given, returns a dict of the heading option values. If
option is specified then the value for that option is returned.
Otherwise, sets the options to the corresponding values.
Valid options/values are:
text: text
The text to display in the colu... | def heading(self, column, option=None, **kw):
| cmd = kw.get('command')
if (cmd and (not isinstance(cmd, basestring))):
kw['command'] = self.master.register(cmd, self._substitute)
if (option is not None):
kw[option] = None
return _val_or_dict(kw, self.tk.call, self._w, 'heading', column)
|
'Returns a description of the specified component under the
point given by x and y, or the empty string if no such component
is present at that position.'
| def identify(self, component, x, y):
| return self.tk.call(self._w, 'identify', component, x, y)
|
'Returns the item ID of the item at position y.'
| def identify_row(self, y):
| return self.identify('row', 0, y)
|
'Returns the data column identifier of the cell at position x.
The tree column has ID #0.'
| def identify_column(self, x):
| return self.identify('column', x, 0)
|
'Returns one of:
heading: Tree heading area.
separator: Space between two columns headings;
tree: The tree area.
cell: A data cell.
* Availability: Tk 8.6'
| def identify_region(self, x, y):
| return self.identify('region', x, y)
|
'Returns the element at position x, y.
* Availability: Tk 8.6'
| def identify_element(self, x, y):
| return self.identify('element', x, y)
|
'Returns the integer index of item within its parent\'s list
of children.'
| def index(self, item):
| return self.tk.call(self._w, 'index', item)
|
'Creates a new item and return the item identifier of the newly
created item.
parent is the item ID of the parent item, or the empty string
to create a new top-level item. index is an integer, or the value
end, specifying where in the list of parent\'s children to insert
the new item. If index is less than or equal to ... | def insert(self, parent, index, iid=None, **kw):
| opts = _format_optdict(kw)
if iid:
res = self.tk.call(self._w, 'insert', parent, index, '-id', iid, *opts)
else:
res = self.tk.call(self._w, 'insert', parent, index, *opts)
return res
|
'Query or modify the options for the specified item.
If no options are given, a dict with options/values for the item
is returned. If option is specified then the value for that option
is returned. Otherwise, sets the options to the corresponding
values as given by kw.'
| def item(self, item, option=None, **kw):
| if (option is not None):
kw[option] = None
return _val_or_dict(kw, self.tk.call, self._w, 'item', item)
|
'Moves item to position index in parent\'s list of children.
It is illegal to move an item under one of its descendants. If
index is less than or equal to zero, item is moved to the
beginning, if greater than or equal to the number of children,
it is moved to the end. If item was detached it is reattached.'
| def move(self, item, parent, index):
| self.tk.call(self._w, 'move', item, parent, index)
|
'Returns the identifier of item\'s next sibling, or \'\' if item
is the last child of its parent.'
| def next(self, item):
| return self.tk.call(self._w, 'next', item)
|
'Returns the ID of the parent of item, or \'\' if item is at the
top level of the hierarchy.'
| def parent(self, item):
| return self.tk.call(self._w, 'parent', item)
|
'Returns the identifier of item\'s previous sibling, or \'\' if
item is the first child of its parent.'
| def prev(self, item):
| return self.tk.call(self._w, 'prev', item)
|
'Ensure that item is visible.
Sets all of item\'s ancestors open option to True, and scrolls
the widget if necessary so that item is within the visible
portion of the tree.'
| def see(self, item):
| self.tk.call(self._w, 'see', item)
|
'If selop is not specified, returns selected items.'
| def selection(self, selop=None, items=None):
| return self.tk.call(self._w, 'selection', selop, items)
|
'items becomes the new selection.'
| def selection_set(self, items):
| self.selection('set', items)
|
'Add items to the selection.'
| def selection_add(self, items):
| self.selection('add', items)
|
'Remove items from the selection.'
| def selection_remove(self, items):
| self.selection('remove', items)
|
'Toggle the selection state of each item in items.'
| def selection_toggle(self, items):
| self.selection('toggle', items)
|
'With one argument, returns a dictionary of column/value pairs
for the specified item. With two arguments, returns the current
value of the specified column. With three arguments, sets the
value of given column in given item to the specified value.'
| def set(self, item, column=None, value=None):
| res = self.tk.call(self._w, 'set', item, column, value)
if ((column is None) and (value is None)):
return _dict_from_tcltuple(res, False)
else:
return res
return
|
'Bind a callback for the given event sequence to the tag tagname.
When an event is delivered to an item, the callbacks for each
of the item\'s tags option are called.'
| def tag_bind(self, tagname, sequence=None, callback=None):
| self._bind((self._w, 'tag', 'bind', tagname), sequence, callback, add=0)
|
'Query or modify the options for the specified tagname.
If kw is not given, returns a dict of the option settings for tagname.
If option is specified, returns the value for that option for the
specified tagname. Otherwise, sets the options to the corresponding
values for the given tagname.'
| def tag_configure(self, tagname, option=None, **kw):
| if (option is not None):
kw[option] = None
return _val_or_dict(kw, self.tk.call, self._w, 'tag', 'configure', tagname)
|
'If item is specified, returns 1 or 0 depending on whether the
specified item has the given tagname. Otherwise, returns a list of
all items which have the specified tag.
* Availability: Tk 8.6'
| def tag_has(self, tagname, item=None):
| return self.tk.call(self._w, 'tag', 'has', tagname, item)
|
'Construct an horizontal LabeledScale with parent master, a
variable to be associated with the Ttk Scale widget and its range.
If variable is not specified, a Tkinter.IntVar is created.
WIDGET-SPECIFIC OPTIONS
compound: \'top\' or \'bottom\'
Specifies how to display the label relative to the scale.
Defaults to \'top\'.... | def __init__(self, master=None, variable=None, from_=0, to=10, **kw):
| self._label_top = (kw.pop('compound', 'top') == 'top')
Frame.__init__(self, master, **kw)
self._variable = (variable or Tkinter.IntVar(master))
self._variable.set(from_)
self._last_valid = from_
self.label = Label(self)
self.scale = Scale(self, variable=self._variable, from_=from_, to=to)
... |
'Destroy this widget and possibly its associated variable.'
| def destroy(self):
| try:
self._variable.trace_vdelete('w', self.__tracecb)
except AttributeError:
pass
else:
del self._variable
Frame.destroy(self)
|
'Adjust the label position according to the scale.'
| def _adjust(self, *args):
| def adjust_label():
self.update_idletasks()
(x, y) = self.scale.coords()
if self._label_top:
y = (self.scale.winfo_y() - self.label.winfo_reqheight())
else:
y = (self.scale.winfo_reqheight() + self.label.winfo_reqheight())
self.label.place_configure(x=... |
'Return current scale value.'
| def _get_value(self):
| return self._variable.get()
|
'Set new scale value.'
| def _set_value(self, val):
| self._variable.set(val)
|
'Construct a themed OptionMenu widget with master as the parent,
the resource textvariable set to variable, the initially selected
value specified by the default parameter, the menu values given by
*values and additional keywords.
WIDGET-SPECIFIC OPTIONS
style: stylename
Menubutton style.
direction: \'above\', \'below\... | def __init__(self, master, variable, default=None, *values, **kwargs):
| kw = {'textvariable': variable, 'style': kwargs.pop('style', None), 'direction': kwargs.pop('direction', None)}
Menubutton.__init__(self, master, **kw)
self['menu'] = Tkinter.Menu(self, tearoff=False)
self._variable = variable
self._callback = kwargs.pop('command', None)
if kwargs:
raise... |
'Build a new menu of radiobuttons with *values and optionally
a default value.'
| def set_menu(self, default=None, *values):
| menu = self['menu']
menu.delete(0, 'end')
for val in values:
menu.add_radiobutton(label=val, command=Tkinter._setit(self._variable, val, self._callback))
if default:
self._variable.set(default)
|
'Destroy this widget and its associated variable.'
| def destroy(self):
| del self._variable
Menubutton.destroy(self)
|
'Initialize a dialog.
Arguments:
parent -- a parent window (the application window)
title -- the dialog title'
| def __init__(self, parent, title=None):
| Toplevel.__init__(self, parent)
self.withdraw()
if parent.winfo_viewable():
self.transient(parent)
if title:
self.title(title)
self.parent = parent
self.result = None
body = Frame(self)
self.initial_focus = self.body(body)
body.pack(padx=5, pady=5)
self.buttonbox(... |
'Destroy the window'
| def destroy(self):
| self.initial_focus = None
Toplevel.destroy(self)
return
|
'create dialog body.
return widget that should have initial focus.
This method should be overridden, and is called
by the __init__ method.'
| def body(self, master):
| pass
|
'add standard button box.
override if you do not want the standard buttons'
| def buttonbox(self):
| box = Frame(self)
w = Button(box, text='OK', width=10, command=self.ok, default=ACTIVE)
w.pack(side=LEFT, padx=5, pady=5)
w = Button(box, text='Cancel', width=10, command=self.cancel)
w.pack(side=LEFT, padx=5, pady=5)
self.bind('<Return>', self.ok)
self.bind('<Escape>', self.cancel)
box.... |
'validate the data
This method is called automatically to validate the data before the
dialog is destroyed. By default, it always validates OK.'
| def validate(self):
| return 1
|
'process the data
This method is called automatically to process the data, *after*
the dialog is destroyed. By default, it does nothing.'
| def apply(self):
| pass
|
'_munge_whitespace(text : string) -> string
Munge whitespace in text: expand tabs and convert all other
whitespace characters to spaces. Eg. " foo bar
baz"
becomes " foo bar baz".'
| def _munge_whitespace(self, text):
| if self.expand_tabs:
text = text.expandtabs()
if self.replace_whitespace:
if isinstance(text, str):
text = text.translate(self.whitespace_trans)
elif isinstance(text, unicode):
text = text.translate(self.unicode_whitespace_trans)
return text
|
'_split(text : string) -> [string]
Split the text to wrap into indivisible chunks. Chunks are
not quite the same as words; see _wrap_chunks() for full
details. As an example, the text
Look, goof-ball -- use the -b option!
breaks into the following chunks:
\'Look,\', \' \', \'goof-\', \'ball\', \' \', \'--\', \' \',
\... | def _split(self, text):
| if isinstance(text, unicode):
if self.break_on_hyphens:
pat = self.wordsep_re_uni
else:
pat = self.wordsep_simple_re_uni
elif self.break_on_hyphens:
pat = self.wordsep_re
else:
pat = self.wordsep_simple_re
chunks = pat.split(text)
chunks = filt... |
'_fix_sentence_endings(chunks : [string])
Correct for sentence endings buried in \'chunks\'. Eg. when the
original text contains "... foo.
Bar ...", munge_whitespace()
and split() will convert that to [..., "foo.", " ", "Bar", ...]
which has one too few spaces; this method simply changes the one
space to two.'
| def _fix_sentence_endings(self, chunks):
| i = 0
patsearch = self.sentence_end_re.search
while (i < (len(chunks) - 1)):
if ((chunks[(i + 1)] == ' ') and patsearch(chunks[i])):
chunks[(i + 1)] = ' '
i += 2
else:
i += 1
|
'_handle_long_word(chunks : [string],
cur_line : [string],
cur_len : int, width : int)
Handle a chunk of text (most likely a word, not whitespace) that
is too long to fit in any line.'
| def _handle_long_word(self, reversed_chunks, cur_line, cur_len, width):
| if (width < 1):
space_left = 1
else:
space_left = (width - cur_len)
if self.break_long_words:
cur_line.append(reversed_chunks[(-1)][:space_left])
reversed_chunks[(-1)] = reversed_chunks[(-1)][space_left:]
elif (not cur_line):
cur_line.append(reversed_chunks.pop())... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.