The tktools module contains assorted
Tk-related subroutines used in some of the user interface tools.
This module was borrowed from the Grail project, even
though only a small fraction of the utilities are used for the
Use of tktools as a 'higher-level' toolkit,
is a way of creating compound widgets using one or more of the
generic Tk widgets in a consistent uniform way throughout all
the graphical applications. Tktools provides functions that
wrap many of the common and repeated idioms used when writing
programs that use Tk.
Installs some common key bindings to various Tk widgets.
Currently it only installs Control-U on an
Entry to clear the field from the beginning
of the field to the insertion point.
Create a Toplevel widget. This is a shortcut
for a Toplevel() instantiation plus calls to
set the title and icon name of the widget.
(widget, master, ... )
Make an existing toplevel widget transient for a
master. The widget must exist but should not yet have been
placed; in other words, this should be called after creating
all the subwidgets but before letting the user see the
window on the display.
Tk Toplevel object to be made
Tk Toplevel object which will become
the master of the newly transient widget
Relative X coordinate adjustment.
Relative Y coordinate adjustment.
Boolean indicating whether the newly transient window
should be exposed before returning to the caller.
Subroutine to create a form entry. This creates three widgets:
a horizontally filling and expanding frame, containing:
a label on the left, and
a text entry on the right.
Text of the new label widget.
Width of the relief border for the new entry widget.
If omitted, the Tk default is used.
(master, label, ... )
-> (Entry or Text instance, Frame
instance, Label instance)
Another subroutine to create a form entry. This is a slightly
modified version of make_form_entry().
This version does the proper alighnment of labels with their
fields. It should probably eventually replace
The one annoying bug is that the text entry field should
be expandable while still aligning the colons. This
doesn't work yet.
Text of the new label widget. If this is not an empty
string and the last character is not a colon
(':'), a colon is added.
Width of the text entry box created.
Height of the text entry box created. If
1, an Entry widget is created,
otherwise a Text widget is created with both
horizontal and vertical scrollbars using
Width of the label field.
Width of the relief border for the text entry box.
Value to be passed as takefocus for
make_text_box() when creating entries more than 1
Create a pair of frames suitable for hosting a
dialog. This method creates a group of nested frames
which provide a simple, clean look & feel, dividing the
parent frame into two main areas: the display frame and
the control frame.
Parent widget. If None, the default root is
Class name of the container frame if not
Widget name of the container frame.
Border relief of the display frame.
Border width of the display frame.
The example dialog below shows a finished dialog created
using make_double_frame(). The most
interesting subframes are indicated by dashed lines.
(master, ... )
-> Frame instance
Create nested frames with a border and optional label.
The outer frame is only used to provide the decorative
border, to control packing, and to host the label. The
inner frame is packed to fill the outer frame and should be
used as the parent of all sub-widgets. Only the inner frame
Widget name for the frame. If not specified, a
generated name will be used.
If specified, text for a label at the top of the
Font for the label specified by label. If
not given, a small font will be used.
Packing options for the resulting frame.
Make buttons passed in all have the same width.
Works for Label and other widgets
with the 'text' parameter, so long as all values
of the 'text' parameter contain only a single
Turn a list or tuple into a single string recursively.
Test whether the string s is a valid Tcl boolean
value. Raises TypeError if s is not a