tkintertoy module

class tt.Window(master=None, extra=False, **tkparms)

Bases: object

An easy GUI creator intended for early Python programmers, built upon Tkinter.

This will create a Tk window with a contents dictionary. The programmer adds “ttwidgets” to the window using the add* methods where the programmer assigns a string tag to a widget. Almost all ttk and most tk widgets are included including some useful combined widgets. I call these ttwidgets because they are not really complex enough to be called “megawidgets”. Most tk/ttk widgets are placed in a frame which can act as a label of the ttwidget to the user. The programmer places the ttwidgets using the plot method which is a synonym for the tkinter grid geometry manager. Contents of the widget are assigned and retrieved by using the tags to the set and get methods. This greatly simplifies working with GUIs. Also, all ttwidgets are bundled into the window object so individual ttwidgets do not need to be passed to other routines, which simplifies interfaces. However, more experienced Python programmers can access the tk/ttk widget and frames directly and take advantage of the full power of Tk and ttk.

In the below methods, not all the possible keyword arguments are listed, only the most common ones were selected. The Tk documentation lists all for every widget. However, tk control variables should NOT be used since they might interfere on how the set and get methods work. Default values are shown in brackets [].

In some themes, certain parameters (like background) will not work in ttk widgets. For this reason, all ttk widgets have an option to use the older tk widget by setting the usetk argument to True.

Parameters:
  • master (tk.Toplevel) – Toplevel window
  • extra (bool) – True if this is an extra window apart from the main
Keyword Arguments:
 
  • borderwidth (int) – Width of border (pixels)
  • height (int) – Height of frame (pixels)
  • padding (int) – Spaces between frame and widgets (pixels)
  • relief (str) – [‘flat’],’raised’,’sunken’,’groove’, or ‘ridge’
  • style (ttk.Style) – Style used for ttk.Frame or ttk.LabelFrame
  • width (int) – Width of frame (pixels)
__contains__(tag)

Checks if widget tag is in window.

Called using the in operator.

Returns:True if ‘tag’ is in window
__len__()

Return number of widgets in window.

Called using the builtin len() function.

Returns:Number of widgets in window
__repr__()

Display content dictionary structure, useful for debugging.

Called using the builtin repr() function.

Returns:String of self.master, self.content
addButton(tag, prompt='', cmd=[], space=3, orient='horizontal', usetk=False, **tkparms)

Create a ttbuttonbox, defaults to Ok - Cancel.

This widget is where one would place most of the command buttons for a GUI, usually at the bottom of the window. Clicking on a button will execute a method usually called a callback. Two basic ones are included; Ok and Cancel. The keyword arguments will apply to EVERY button.

Parameters:
  • tag (str) – Reference to widget
  • prompt (str) – Text of frame label
  • cmd (list) – (label:str, callback:function) for each button
  • space (int) – space (pixels) between buttons
  • orient (str) – [‘horizontal’] or ‘vertical’
  • usetk (bool) – Use tk instead of ttk
Keyword Arguments:
 
  • compound (str) – Display both image and text, see ttk docs
  • image (tk.PhotoImage) – GIF/PNG image to display
  • style (ttk.Style) – Style to use for checkboxes
  • width (int) – Width of label (chars)
Returns:

list(ttk/tk.buttons)

addCanvas(tag, width, height, prompt='', **tkparms)

Create a ttcanvas window.

The tk.Canvas is another extremely powerful widget that displays graphics. Again, read the Tkinter documentation to discover all the features of this widget.

Parameters:
  • tag (str) – Reference to widget
  • width (int) – Width of window (pixels)
  • height (int) – Height of window (pixels)
  • prompt (str) – Text of frame label
Keyword Arguments:
 
  • background (str) – Background color
  • closeenough (float) – Mouse threshold
  • confine (bool) – Canvas cannot be scrolled ourside scrolling region
  • cursor (str) – Mouse cursor
  • scrollregion (list of int) – w, n, e, s bondaries of scrolling region
Returns:

tk.canvas

addCheck(tag, prompt='', alist=[], orient='horizontal', usetk=False, **tkparms)

Create a ttcheckbutton box.

Checkboxes are used to collect options from the user, similar to a listbox. Checkboxes might be better for short titled options because they don’t take up as much screen space. The keyword arguments will apply to EVERY checkbutton. Get/set uses list of str.

Parameters:
  • tag (str) – Reference to widget
  • prompt (str) – Text of frame label
  • alist (list) – (str1, str2, …)
  • orient (str) – [‘horizontal’] or ‘vertical’
  • usetk (bool) – Use tk instead of ttk
Keyword Arguments:
 
  • command (callback) – Function to execute when boxes are toggled
  • compound (str) – Display both image and text, see ttk docs
  • image (tk.PhotoImage) – GIF image to display
  • style (ttk.Style) – Style to use for checkboxes
  • width (int) – Width of max checkbox label (chars), negative sets minimum
Returns:

[ttk/tk.checkbuttons]

addChooseDir(tag, prompt='', width=20, **tkparms)

Create a ttchoosedir box which is a directory entry with a browse button.

This has all the widgets needed to select a directory. When the user clicks on the Browse button, a standard Choose Directory dialog box pops up. There are many tkparms that are useful for limiting choices, see the Tk documentation. Get/set uses str. Normally, this would be use in a dialog. For a menu command use popChooseDir.

Parameters:
  • tag (str) – Reference to widget
  • prompt (str) – Text of frame label
  • width (int) – Width of entry widget
Keyword Arguments:
 
  • initialdir (str) – Initial directory (space, ‘ ‘ remembers last directory)
  • title (str) – Pop-up window’s title
Returns:

list(ttk/tk.entry, ttk/tk.button)

addCollector(tag, height, columns, widgets, prompt='', **tkparms)

Create a ttcollector which is based on a treeview that collects contents of other widgets.

This collection of widgets allows the programmer to collect the contents of other widgets into a row. The user can add or delete rows as they wish using the included buttons. Get/set uses list of str. There is no tk version.

Parameters:
  • tag (str) – Reference to widget
  • height (int) – Height of widget
  • columns (list) – (Column headers, width (pixels))
  • widgets (list) – (Tags) for simple or (window, tag) for embedded widgets
  • prompt (str) – Text of frame label
Keyword Arguments:
 
  • padding (int) – Spaces around values
  • style (ttk.Style) – Style used for ttk.Treeview
Returns:

[ttk.treeview, ttk.button, ttk.button]

addCombo(tag, prompt='', values=None, **tkparms)

Create a ttcombobox.

Comboboxes combine features of Entry and Listbox into a single widget. The user can select one option out of the list or even type in their own. It is better than listboxes for a large number of options. Due to problems with textvariable in nested frames with ttk, they are not used. Get/set uses str. There is no tk version.

Parameters:
  • tag (str) – Reference to widget
  • prompt (str) – Text of frame label
  • values (list) – (str1, str2, …)
Keyword Arguments:
 
  • height (int) – Maximum number of rows in dropdown [10]
  • justify (str) – Justification of text ([‘left’], ‘right’, ‘center’)
  • postcommand (callback) – Function to call when user clicks on downarrow
  • style (ttk.Style) – Style to use for widget
  • width (int) – Width of label (chars) [20]
Returns:

ttk.combobox

addEntry(tag, prompt='', usetk=False, **tkparms)

Create an ttentry.

Entries are the widget to get string input from the user. Due to problems with textvariables in nested frames with ttk, they are not used. Get/set uses str.

Parameters:
  • tag (str) – Reference to widget
  • prompt (str) – Text of frame label
  • usetk (bool) – Use tk instead of ttk
Keyword Arguments:
 
  • justify (str) – Justification of text (‘left’ [def], ‘right’, ‘center’)
  • show (str) – Char to display instead of actual text
  • style (ttk.Style) – Style to use for widget
  • width (int) – Width of label [20] (chars)
Returns:

ttk/tk.entry

addFrame(tag, prompt='', usetk=False, **tkparms)

Create a labeled or unlabeled frame container.

This allows the programmer to group widgets into a new window. The window can have either a title or a relief style, but not both.

Parameters:
  • tag (str) – Reference to container
  • prompt (str) – Text of frame label
  • usetk (bool) – Use tk instead of ttk
Keyword Arguments:
 
  • boarderwidth (int) – width of border (for relief styles only)
  • height (int) – Height of frame (pixels)
  • padding (int) – Spaces between frame and widgets (pixels)
  • relief (str) – ‘flat’,’raised’,’sunken’,’groove’, or ‘ridge’
  • style (int) – Style used for ttk.Frame or ttk.LabelFrame
  • width (int) – Width of frame (pixels)
Returns:

tt.window

addLabel(tag, prompt='', effects='', usetk=False, **tkpamrs)

Create a ttlabel.

Labels are used to display simple messages to the user. Due to problems with textvariable in nested frames with ttk, the textvariable is not used. An effects parameter is included for the simplest font types but this will override the font keyword argument. Get/set uses str.

Parameters:
  • tag (str) – Reference to widget
  • prompt (str) – Text of frame label
  • effects (str) – ‘bold’ and/or ‘italic’
  • usetk (bool) – Use tk instead of ttk
Keyword Arguments:
 
  • anchor (str) – Position in widget; [‘c’], ‘w’, ‘e’)
  • background (str) – Background color
  • compound (str) – Display both image and text, see ttk docs
  • font (tkfont.Font) – Font for label
  • foreground (str) – Text color
  • image (tk.PhotoImage) – GIF image to display
  • justify (str) – Justification of text; [‘left’], ‘right’, ‘center’
  • padding (list) – Spacing (left, top, right, bottom) around widget (pixels)
  • text (str) – The text inside the widget
  • width (int) – Width of label (chars)
  • wraplength (int) – Character position to word wrap
Returns:

ttk/tk.label

addLedger(tag, height, columns, prompt='', **tkparms)

Create a ttledger which is based on a treeview that displays a simple list with column headers.

This widget allows a nice display of data in columns. It is a simplified version of the Collector widget. Due to a bug in ttk, sideways scrolling does not work correctly. If you need sideways scrolling use the Text widget. Get/set uses list of str. There is no tk version.

Parameters:
  • tag (str) – Reference to widget
  • height (int) – Height of widget
  • columns (list) – (Column headers, width (pixels))
  • prompt (str) – Text of frame label
Keyword Arguments:
 
  • padding (int) – Spaces around values
  • selectmode (str) – [‘browse’] or ‘extended’
  • (ttk (style) – Style): Style used for ttk.Treeview
Returns:

ttk.treeview

addLine(tag, **tkparms)

Create a horizontal or vertical ttline across the entire frame.

Lines are useful for visually separating areas of widgets. They have no frame. There is no tk version.

Parameters:

tag (str) – Reference to widget

Keyword Arguments:
 
  • orient (str) – [‘horizontal’] or ‘vertical’
  • style (ttk.Style) – Style to use for line
Returns:

ttk.separator

addList(tag, prompt='', alist=[], **tkparms)

Create a ttlistbox.

Listboxes allow the user to select a series of options in a vertical list. It is best for long titled options but does take up some screen space. This implementation avoids the listvariable. Since this is a Tk widget, there is no style keyword argument. Get/set uses list of str.

Parameters:
  • tag (str) – Reference to widget
  • prompt (str) – Text of frame label
  • alist (list) – (str1, str2, …)
Keyword Arguments:
 
  • background (str) – Background color
  • font (tkfont.Font) – Font for label
  • foreground (str) – Text color
  • height (int) – Height of listbox (chars) [10]
  • selectmode (str) – [‘browse’], ‘single’, ‘multiple’, or ‘extended’
  • width (int) – Width of label (chars) [20]
Returns:

tk.listbox

addMenu(tag, parent, items=None, **tkparms)

Add a menu

Menus are complex so read the Tk documentation carefully.

Parameters:
  • tag (str) – Reference to menu
  • parent (ttk.Menubutton or tk.Frame) – What menu is attached to
  • items (list) – (‘cascade’ or ‘checkbutton’ or ‘command’ or ‘radiobutton’ or ‘separator’, coptions) (see Tk Documentation)
Keyword Arguments:
 

Varies (dict) – see Tk documentation

Returns:

tk.menu

addMenuButton(tag, usetk=False, **tkparms)

Add a menu button

A menubuuton always stays on the screen and is what the user clicks on. A menu is attached to the menubutton. Menus are complex so read the Tk documentation carefully.

Parameters:tag (str) – Reference to menubutton
Keyword Arguments:
 Varies (dict) – see Tk documentation
Returns:ttk/tk.menubutton
addMessage(tag, prompt, **tkparms)

Create a ttmessage which is like multiline label.

Messages are used to display multiline messages to the user. This is a tk widget so the list of options is extensive. Due to problems with textvariables in nested ttk windows, they are not used. This widget’s behavior is a little strange so you might prefer the Text or Label widgets. Get/set uses str.

Parameters:
  • tag (str) – Reference to widget
  • prompt (str) – Text of frame label
Keyword Arguments:
 
  • aspect (int) – Ratio of width to height
  • background (str) – Background color
  • borderwidth (int) – Width of border (pixels)
  • font (tkfont.Font) – Font for label
  • foreground (str) – Text color
  • justify (str) – Justification of text; [‘left’], ‘right’, ‘center’
  • padx (int) – Horizontal spaces to place around widget (pixels)
  • pady (int) – Vertical spaces to place around widget (pixels)
  • relief (str) – ‘flat’,’raised’,’sunken’,’groove’, or ‘ridge’
  • text (str) – The text inside the widget
  • width (int) – Width of message (pixels)
Returns:

tk.message

addNotebook(tag, tabs, **tkparms)

Create a tabbed notebook container.

This allows the programmer to group similar pages into a series of new windows. The user selected the active window by clicking on the tab. Assignment allows the program to display a page number (counting from 0), and return the currently selected page number. There is no frame. Get/set uses int. Ther is no tk version.

Parameters:
  • tag (str) – Reference to container
  • tabs (list) – (Tab Titles)
Keyword Arguments:
 
  • height (int) – Height of frame (pixels)
  • padding (int) – Spaces between frame and widgets (pixels)
  • style (int) – Style used for ttk.Frame or ttk.LabelFrame
  • width (int) – Width of frame (pixels)
Returns:

list(tt.windows)

addOpen(tag, prompt='', width=20, **tkparms)

Create a ttopen box which is a file entry and a browse button.

This has all the widgets needed to open a file. When the user clicks on the Browse button, a standard Open dialog box pops up. There are many tkparms that are useful for limiting choices, see the Tk documentation. Get/set uses str. Normally, this widget would be in a dialog. For a menu command use popOpen.

Parameters:
  • tag (str) – Reference to widget
  • prompt (str) – Text of frame label
  • width (int) – Width of entry widget (chars)
Keyword Arguments:
 
  • defaultextension (str) – extention added to filename (must strat with .)
  • filetypes (list) – entrys in file listing ((label1, pattern1), (…))
  • initialdir (str) – Initial directory (space, ‘ ‘ remembers last directory)
  • initialfile (str) – Default filename
  • title (str) – Pop-up window’s title
Returns:

list(ttk/tk.entry, ttk/tk.button)

addOption(tag, prompt='', alist=[])

Create an ttoptionmenu.

Option menus allow the user to select one fixed option, similar to Radiobutton. However, option menu returns a tk.Menu and is more difficult to manipulate. There are no keyword arguments in tk.OptionMenu. Get/set uses str.

Parameters:
  • tag (str) – Reference to widget
  • prompt (str) – Text of frame label
  • alist (list) – (str1, str2, …)
Returns:

tk.optionmenu

addPanes(tag, titles, usetk=False, **tkparms)

Create a multipaned window with user adjustable columns.

This is like a notebook but all the windows are visible. There is no frame.

Parameters:
  • tag (str) – Reference to container
  • titles (list) – (titles) of all embedded windows
  • usetk (bool) – Use tk instead of ttk
Keyword Arguments:
 
  • height (int) – Height of frame (pixels)
  • orient (str) – [‘horizontal’] or ‘vertical’
  • padding (int) – Spaces between frame and widgets (pixels)
  • style (int) – Style used for ttk.Frame or ttk.LabelFrame
  • width (int) – Width of frame (pixels)
Returns:

[tt.windows]

addProgress(tag, length, prompt='', orient='horizontal', **tkparms)

Create a ttprogressbar.

This indicates to the user how an action is progressing. The included method supports a determinate mode where the programmer tells the user exactly how far they have progressed. Ttk also supports a indeterminate mode where a rectangle bounces back a forth. See the Tk documentation. Get/set uses int. There is no tk version.

Parameters:
  • tag (str) – Reference to widget
  • length (int) – Length of widget (pixels)
  • prompt (str) – Text of frame label
  • orient (str) – ‘horizontal’ or ‘vertical’
Keyword Arguments:
 
  • maximum (int) – Maximum value [100]
  • mode (str) – [‘determinate’] or ‘indeterminate’
  • style (str) – Style to use for ttk.Progressbar
Returns:

ttk.progressbar

addRadio(tag, prompt='', alist=[], orient='horizontal', usetk=False, **tkparms)

Create a ttradiobutton box.

Radiobuttons allow the user to select only one option. If they change options, the previous option is unselected. This was the way old car radios worked hence its name. They are better for short titled options. The keyword arguments will apply to EVERY radiobutton. Get/set uses str.

Parameters:
  • tag (str) – Reference to widget
  • prompt (int) – Text of frame label
  • alist (list) – (str1, str2, …)
  • orient (str) – ‘horizontal’ or ‘vertical’
  • usetk (bool) – Use tk instead of ttk
Keyword Arguments:
 
  • command (callback) – Function to execute when boxes are toggled
  • compound (str) – Display both image and text, see ttk docs
  • image (tk.PhotoImage) – GIF image to display
  • style (ttk.Style) – Style to use for checkboxes
  • width (int) – Width of max label (chars), negative sets minimun
Returns:

[ttk/tk.radiobuttons]

addSaveAs(tag, prompt='', width=20, **tkparms)

Create an ttsaveas box which is a file entry with a browse button.

This has all the widgets needed to save a file. When the user clicks on the Browse button, a standard SaveAs dialog box pops up. If the user selects an existing file, it will pop up a overwrite confirmation box. There are many tkparms that are useful for limiting choices, see the Tk documentation. Get/set uses str. Normally, this widget would be in a dialog. For a menu command, use popOpen.

Parameters:
  • tag (str) – Reference to widget
  • prompt (str) – Text of frame label
  • width (int) – Width of entry widget
Keyword Arguments:
 
  • defaultextension (str) – extention added to filename (must strat with .)
  • filetypes (list) – entrys in file listing ((label1, pattern1), (…))
  • initialdir (str) – Initial directory (space, ‘ ‘ remembers last directory)
  • initialfile (str) – Default filename
  • title (str) – Pop-up window’s title
Returns:

list(ttk/tk.entry, ttk/tk.button)

addScale(tag, parms, prompt='', width=20, usetk=False, **tkparms)

Create a ttscale which is an integer scale with entry box.

Scale allows the user to enter an integer value using a sliding scale. The user can also type in a value directly in the entry box. Get/set uses int.

Parameters:
  • tag (str) – Reference to widget
  • parms (list) – Limits of scale (from, to)
  • prompt (str) – Text of frame label
  • width (int) – Width of entry widget (chars)
  • usetk (bool) – Use tk instead of ttk
Keyword Arguments:
 
  • command (callback) – Function to call when scale changes
  • length (int) – Length of scale (pixels) [100]
  • orient (str) – ‘horizontal’ or ‘vertical’
  • style (str) – Style to use for ttk.Scale
Returns:

list(ttk/tk.scale, ttk/tk.entry)

addScrollbar(tag, widgetTag, orient='horizontal', usetk=False, **tkparms)

Add a scrollbar to a widget.

This is usually this is done automatically. There is no frame. In order to plot the programmer must get the widget frame and use the correct sticky option. It was included for completeness.

Parameters:
  • tag (str) – Reference to widget
  • widgetTag (str) – Tag of connected widget
  • orient (str) – [‘horizontal’] or ‘vertical’
Keyword Arguments:
 

style (ttk.Style) – Style used for ttk.Scrollbar

Returns:

ttk/tk.scrollbar

addSizegrip(tag, **tkparms)

Add a sizegrip widget to the window.

This places a sizegrip in the bottom right corner of the window. It is not needed since most platforms add this automatically. The programmer must use the configurerow and configurecolumn options when plotting widgets for this to work correctly. There is no frame. It was included for completeness. There is no tk version.

Parameters:tag (str) – Reference to widget
Keyword Arguments:
 style (ttk.Style) – Style used for ttk.Sizegrip, mainly background
Returns:ttk.sizegrip
addSpin(tag, parms, between='', prompt='', usetk=False, **tkparms)

Create a ttspinbox.

Spinboxes allow the user to enter a series of integers. It is best used for items like dates, time, etc. The keyword arguments will apply to EVERY spinbox. Since this is a Tk widget, there is no style keyword argument. Get/set uses list of int.

Parameters:
  • tag (str) – Reference to widget
  • parms (list) – Parmeters for each spinbox ((width, from, to),…)
  • between (str) – Label between each box
  • prompt (str) – Text of frame label
  • usetk (bool) – Use tk instead of ttk
Keyword Arguments:
 
  • command (callback) – Function to call when arrows are clicked
  • style (ttk.Style) – Style to use for widget
  • justify (str) – Text justification; [‘left’], ‘right’, ‘center’
  • wrap (bool) – Arrow clicks wrap around
Returns:

list(ttk/tk.spinboxes)

addStyle(tag, **tkparms)

Add a ttk.Style to be used for other widgets.

This is the method for changing the appearance of ttk widgets. Styles are strictly defined strings so look at the Tk documentation.

Parameter:
tag (str): Reference to style, must follow ttk naming
Keyword Arguments:
 with widget, see Tk documentation (Varies) –
addText(tag, width, height, prompt='', **tkparms)

Create a tttext window.

The tk.Text widget is an extremely powerful widget that can do many things, other than just displaying text. It is almost a mini editor. The default method allow the programmer to add and delete text. Be sure to read the Tk documentation to discover all the features of this widget. Since this is a Tk widget, there is no style keyword argument. Get/set uses str.

Parameters:
  • tag (str) – Reference to widget
  • width (int) – Width of window (chars)
  • height (int) – Height of window (chars)
  • prompt (str) – Text of frame label
Keyword Arguments:
 
  • background (str) – Background color
  • font (tkfont.Font) – Text font
  • foreground (str) – Text color
  • wrap (str) – Wordwrap method; [‘char’], ‘word’, or ‘none’
Returns:

tk.text

breakout()

Exit the mainloop but don’t destroy the master.

This stops the event loop, but window remains displayed.

cancel()

Clear contents and exit mainloop.

This stops the event loop, removes the window, and deletes the widget structure.

catchExcept()

Catch the exception messages.

Use this in a try/except block to catch any errors:

Returns:The exception message
Return type:str
changeState(tag, index=None, *states)

Set or clear ttk or tk widget states

Change the underlying ttk or tk widget states. For ttk widgets the states are ‘active’, ‘alternate’, background’, ‘disabled’, ‘focus’, ‘invalid’, ‘pressed’, ‘readonly’, and ‘selected’. Preceding a state with ‘!’ clears it. For tk widgets use ‘disabled’ or ‘normal’. Index parameter allows you to change an individual element in multipart widget. See Tk documentation.

Parameters:
  • tag (str) – Reference to widget
  • index (int) – Index to element in multipart widget
  • states (list) – States of widget, usually [‘disabled’] or [‘!disabled’]
changeWidget(tag, index=None, **tkparms)

Change a tk/ttk widget

Change the underlying tk or ttk widget appearance using tkparms. Index parameter allows you to change an individual element in multipart widget. See Tk documentation.

Parameters:
  • tag (str) – Reference to widget
  • index (int) – Index to element in multipart widget
Keyword Arguments:
 
  • justify (str) – Justification of text (‘left’ [def], ‘right’, ‘center’)
  • show (str) – Char to display instead of actual text
  • style (ttk.Style) – Style to use for widget
  • text (str) – Text inside widget
close()

Close the window.

This stops the event loop and removes the window. However, the window structure can still be referenced, and the window can be redisplayed.

focus(tag)

Switch focus to the desired widget.

This is useful to select the desired widget at the beginning so the user does not have to click.

Parameters:tag (str) – Reference to widget
get(tag, allValues=False)

Get the contents of the ttwidget. With more complex widgets the programmer can choose to get all the values rather than user selected values.

Parameters:
  • tag (str) – Reference to widget, created in add*
  • allValues (bool) – if true return all the values
Returns:

Contents of ttwidget

getFrame(tag)

Get the ttk frame if present.

Get the ttk.Frame or ttk.LabelFrame of the widget so the programmer can use more advanced methods.

Parameters:tag (str) – Reference to widget
Returns:ttk/tk.Frame or ttk/tk.LabelFrame
getType(tag)

Get the type of widget.

Get the type of widget as a string. All widgets have a type.

Parameters:tag (str) – Reference to widget
Returns:Type of widget as str
getWidget(tag)

Get the tk/ttk widget if present.

Get the underlying tk or ttk widget so the programmer can use more advanced methods.

Parameter:
tag (str): - Reference to widget
Returns:The ttk/tk widget
plot(tag=None, **tkparms)

Plot the ttwidget.

Place a frame and widget in a cell of a window using the row and column. Plot was selected as an easier name for beginners than grid. Other tkparms are extremely useful here and should be understood. Look at the Tk documentation.

Parameters:

tag (str) – Reference to widget

Keyword Arguments:
 
  • row (int) – the row number counting from 0
  • column (int) – the column number
  • rowspan (int) – the number of rows to span
  • columnspan (int) – the number of columns to span
  • sticky (str) – the directions to fill the cell for the widget
  • rowconfigure (int) – rate widget expands in vertical if resized
  • columnconfigure (int) – rate widget expands in horizontal
  • padx (int) – horizontal space between widget cells (pixels)
  • pady (int) – vertical space between widget cells (pixels)
  • ipadx (int) – horizontal space within cell (pixels)
  • ipady (int) – vertical space within cell (pixels)
popChooseDir(**tkparms)

Popup a choose directory dialog

This pops up a standard choose directory dialog. Normally, one would use addChooseDir.

Keyword Arguments:
 
  • initialdir (str) – Initial directory (space, ‘ ‘ remembers last directory)
  • title (str) – Pop-up window’s title
Returns:

str

popColorChooser(**tkparms)

Popup a color chooser dialog.

This pops up a standard color chooser dialog.

Keyword Arguments
color (str): Initial color title (str): Title of pop-up window [‘Color’]
Returns:(red, green blue)
popMessage(message, mtype='showinfo', title='Information', **tkparms)

Popup a tk message window.

Parameters:
  • message (str) – Message in box
  • mtype (str) – ‘showinfo’ or ‘showwarning’ or ‘showerror’ or ‘askyesno’ or ‘askokcancel’ or ‘askretrycancel’
  • title (str) – Title of window
Keyword Arguments:
 
  • default (str) – ‘OK’ or ‘Cancel’ or ‘Yes’ or ‘No’ or ‘Retry’
  • icon (str) – ‘error’ or ‘info’ or ‘question’ or ‘warning’
Returns:

‘ok’ for show*, bool for ask*

popOpen(**tkparms)

Popup a open dialog

This pops up a standard open dialog.

Keyword Arguments:
 
  • defaultextension (str) – extention added to filename (must strat with .)
  • filetypes (list) – entrys in file listing ((label1, pattern1), (…))
  • initialdir (str) – Initial directory (space, ‘ ‘ remembers last directory)
  • initialfile (str) – Default filename
  • title (str) – Pop-up window’s title
Returns:

str

popSaveAs(**tkparms)

Popup a save as dialog

This pops up a standard save as dialog.

Keyword Arguments:
 
  • defaultextension (str) – extention added to filename (must strat with .)
  • filetypes (list) – entrys in file listing ((label1, pattern1), (…))
  • initialdir (str) – Initial directory (space, ‘ ‘ remembers last directory)
  • initialfile (str) – Default filename
  • title (str) – Pop-up window’s title
Returns:

str

refresh()

Alias for update_idletasks, better label for beginners.

This refreshes the appearance of all widgets. Usually this is called automatically after a widget contents are changed.

set(tag, value, allValues=False)

Set the contents of the widget. The programmer has the option to replace all the values or just add new values.

Parameters:
  • tag (str) –
    • Reference to widget
  • value (object) –
    • Value to set
  • allValues (bool) – if True, replace all values
setTitle(prompt)

Set the title for a window

This allows the programmer to set the title of the window. If this method is not used, the title will be Tk. This only works with top level windows.

Parameters:prompt (str) – The title of the window
ver = 1.3
waitforUser()

Alias for mainloop, better label for beginners.

This starts the event loop so the user can interact with window.