tkgui.controls module

Controls used by the TKinter GUI.

class tkgui.controls.Button(master=None, **kw)[source]

Bases: Button

tkgui.controls.add_default_to_entry(entry, default_text)[source]

Adds bindings to entry such that when there is no user text in the entry, the entry will display default_text in grey and italics.

tkgui.controls.create_control_group(parent, text, dual_column=False)[source]

Creates and returns a Frame or Labelframe to group controls.

Parameters:
  • text – the caption for the Labelframe. If None, returns a Frame.

  • dual_column – configure the frame for a dual-column grid layout if True.

tkgui.controls.create_file_list(parent, title, listvar, **args)[source]

Creates a file list with a scrollbar. Returns a tuple (frame, listbox).

Parameters:
  • parent – The parent control for the list.

  • title – The title for the frame.

  • listvar – The variable containing the list items.

  • args – Additions keyword arguments for the file list itself.

Returns:

(tuple, listbox)

tkgui.controls.create_file_list_buttons(parent, title, listvar, load_fn, refresh_fn, save_fn, delete_fn, **args)[source]

Creates a file list with load, refresh, save and delete buttons. Returns a tuple (frame, listbox, buttons).

Parameters:
  • parent – The parent control for the list.

  • title – The title for the frame.

  • listvar – The variable containing the list items.

  • load_fn – Reference to a function to be called when the Load button is clicked.

  • refresh_fn – Reference to a function to be called when the Refresh button is clicked.

  • save_fn – Reference to a function to be called when the Save button is clicked.

  • delete_fn – Reference to a function to be called when the Delete button is clicked.

  • args – Additions keyword arguments for the file list itself.

Returns:

(frame, listbox, buttons)

tkgui.controls.create_list_with_entry(parent, title, listvar, buttonspec, **kwargs)[source]

Creates a control group with a listbox, a text entry, and any number of buttons specified with buttonspec. Does not lay out the control group in its parent.

Parameters:
  • parent – The parent control for the list.

  • title – The title for the frame.

  • listvar – The variable containing the list items.

  • buttonspec – A list of tuples (title, tooltip, function) specifying the buttons

Returns:

a tuple (frame, entry, lsitbox)

tkgui.controls.create_numeric_entry(parent, variable, option, tooltip)[source]

Creates and returns an Entry suitable for input of small, numeric values and hooks up notification of changes.

Parameters:
  • parent – The parent control for the Entry.

  • variable – The StringVar used to store the value internally.

  • option – The keyword used for the option.

  • tooltip – The tooltip for the Entry.

tkgui.controls.create_option_button(parent, text, tooltip, option, update_func=None)[source]

Creates and returns a button bound to an option.

Parameters:
  • parent – the parent control for the button.

  • text – the button text.

  • tooltip – the tooltip for the button.

  • option – the keyword used for the option.

  • update_func – if given, a reference to a function that pre-processes the given option for display.

tkgui.controls.create_readonly_file_list_buttons(parent, title, listvar, load_fn, refresh_fn, **args)[source]

Creates a file list with load and refresh buttons. Returns a tuple (frame, listbox, buttons).

Parameters:
  • parent – The parent control for the list.

  • title – The title for the frame.

  • listvar – The variable containing the list items.

  • load_fn – Reference to a function to be called when the Load button is clicked.

  • refresh_fn – Reference to a function to be called when the Refresh button is clicked.

  • args – Additions keyword arguments for the file list itself.

Returns:

(frame, listbox, buttons)

tkgui.controls.create_scrollbar(parent, control, **gridargs)[source]

Creates and layouts a vertical scrollbar associated to <control>.

Parameters:
  • parent – the parent control for the scrollbar.

  • control – the control to attach the scrollbar to.

  • gridargs – Keyword arguments used to apply grid layout to the scrollbar.

tkgui.controls.create_toggle_list(parent, columns, framegridopts, listopts=None)[source]

Creates and returns a two-column Treeview in a frame to show toggleable items in a list.

Parameters:
  • parent – The parent control for the Treeview.

  • columns – Column data for the Treeview.

  • framegridopts – Additional options for grid layout of the frame.

  • listopts – Additional options for the Treeview.

tkgui.controls.create_tooltip(widget, text)[source]

Creates and returns a tooltip for a widget.

Parameters:
  • widget – the widget to associate the tooltip to.

  • text – the tooltip text.

tkgui.controls.create_trigger_button(parent, text, tooltip, command)[source]

Creates and returns a button that triggers an action when clicked.

Parameters:
  • parent – The parent control for the button.

  • text – The button text.

  • tooltip – The tooltip for the button.

  • command – Reference to the function called when the button is clicked.

tkgui.controls.create_trigger_option_button(parent, text, tooltip, command, option, update_func=None)[source]

Creates and returns a button bound to an option, with a special action triggered on click.

Parameters:
  • parent – the parent control for the button.

  • text – the button text.

  • tooltip – the tooltip for the button.

  • command – Reference to the function called when the button is clicked.

  • option – the keyword used for the option.

  • update_func – f given, a reference to a function that pre-processes the given option for display.

tkgui.controls.init(ui)[source]

Connect to a TkGui instance.

tkgui.controls.listbox_dyn_tooltip(listbox, item_get, tooltip_get)[source]

Attaches a dynamic tooltip to a listbox.

Parameters:
  • listbox – The listbox to attach to.

  • item_get – A function taking the index of the item and returning a reference to the item.

  • tooltip_get – A function taking a reference to an item and returning its tooltip (or the empty string for no tooltip).

tkgui.controls.listbox_identify(listbox, y)[source]

Returns the index of the listbox item at the supplied (relative) y coordinate

tkgui.controls.treeview_tag_set(tree, tag, item, state=True, toggle=False)[source]

Adds or removes a tag from the Treeview item’s tags. Returns True if tag is now set or False if it is not.

Parameters:
  • item – Treeview item id

  • state – True to set the tag; False to remove the tag.

  • toggle – If set to True, will toggle the tag. Overrides on.