1.1.4.2. managers

This module contains classes used for high level management of some GTK widgets.

1.1.4.2.1. Classes

class ButtonGroupManager(glade_gobject, widget_type, group_name)[source]

Bases: object

Manage a set of buttons. The buttons should all be of the same type (such as “checkbutton” or “radiobutton”) and include a common group name prefix. The intent is to make managing buttons of similar functionality easier by grouping them together.

__init__(glade_gobject, widget_type, group_name)[source]
Parameters
  • glade_gobject (GladeGObject) – The gobject which has the radio buttons set.

  • group_name (str) – The name of the group of buttons.

class MenuManager(menu=None)[source]

Bases: object

A class that wraps Gtk.Menu objects and facilitates managing their respective items.

__init__(menu=None)[source]
Parameters

menu (Gtk.Menu) – An optional menu to start with. If a menu is specified it is used as is, otherwise a new instance is used and is set to be visible using show().

append(label, activate=None, activate_args=())[source]

Create and append a new Gtk.MenuItem with the specified label to the menu.

Parameters
  • label (str) – The label for the new menu item.

  • activate – An optional callback function to connect to the new menu item’s activate signal.

Returns

Returns the newly created and added menu item.

Return type

Gtk.MenuItem

append_item(menu_item, set_show=True)[source]

Append the specified menu item to the menu.

Parameters
  • menu_item (Gtk.MenuItem) – The item to append to the menu.

  • set_show (bool) – Whether to set the item to being visible or leave it as is.

append_submenu(label)[source]

Create and append a submenu item, then return a new menu manager instance for it.

Parameters

label (str) – The label for the new menu item.

Returns

Returns the newly created and added menu item.

Return type

Gtk.MenuManager

class RadioButtonGroupManager(glade_gobject, group_name)[source]

Bases: ButtonGroupManager

Manage a group of Gtk.RadioButton objects together to allow the active one to be easily set and identified. The buttons are retrieved from a GladeGObject instance and must be correctly named in the dependencies attribute as ‘radiobutton_group_name_button_name’.

__init__(glade_gobject, group_name)[source]
Parameters
  • glade_gobject (GladeGObject) – The gobject which has the radio buttons set.

  • group_name (str) – The name of the group of buttons.

get_active()[source]

Return the name of the active button if one in the group is active. If no button in the group is active, None is returned.

Returns

The name of the active button.

Return type

str

set_active(button)[source]

Set a button in the group as active.

Parameters

button (str) – The name of the button to set as active.

class TimeSelectorButtonManager(application, button, value=None)[source]

Bases: object

A manager class to convert a ToggleButton to be used for showing a time selector py:class:~.Gtk.Popover object with inputs for setting the hour and minutes. This then exposes the selected time through the time attribute.

time[source]
__init__(application, button, value=None)[source]
Parameters
  • button (Gtk.ToggleButton) – The button used for activation.

  • application – The application instance which owns this object.

  • value (datetime.time) – The present datetime value (defaults to 00:00).

property time[source]

This property represents the current time value and when set, updates the associated button.

Returns

The current time value.

Return type

datetime.time

class ToggleButtonGroupManager(glade_gobject, widget_type, group_name)[source]

Bases: ButtonGroupManager

Manage a mapping of button names to a boolean value indicating whether they are active or not.

get_active()[source]

Get the button names and whether or not they are active.

Returns

A mapping of button names to whether or not they are active.

Return type

dict

set_active(buttons)[source]

Set the specified buttons to active or not.

Parameters

buttons (dict) – A mapping of button names to boolean values.

class TreeViewManager(treeview, selection_mode=None, cb_delete=None, cb_refresh=None)[source]

Bases: object

A class that wraps Gtk.TreeView objects that use Gtk.ListStore models with additional functions for conveniently displaying text data.

If cb_delete is specified, the callback will be called with the treeview instance, and the selection as the parameters.

If cb_refresh is specified, the callback will be called without any parameters.

__init__(treeview, selection_mode=None, cb_delete=None, cb_refresh=None)[source]
Parameters
  • treeview (Gtk.TreeView) – The treeview to wrap and manage.

  • selection_mode (Gtk.SelectionMode) – The selection mode to set for the treeview.

  • cb_delete (function) – An optional callback that can be used to delete entries.

cb_delete[source]

An optional callback for deleting entries from the treeview’s model.

cb_refresh[source]

An optional callback for refreshing the data in the treeview’s model.

column_titles[source]

An ordered dictionary of storage data columns keyed by their respective column titles.

column_views[source]

A dictionary of column treeview’s keyed by their column titles.

get_popup_copy_submenu()[source]

Create a Gtk.Menu with entries for copying cell data from the treeview.

Returns

The populated copy popup menu.

Return type

Gtk.Menu

get_popup_menu(handle_button_press=True)[source]

Create a Gtk.Menu with entries for copying and optionally delete cell data from within the treeview. The delete option will only be available if a delete callback was previously set.

Parameters

handle_button_press (bool) – Whether or not to connect a handler for displaying the popup menu.

Returns

The populated popup menu.

Return type

Gtk.Menu

set_column_color(background=None, foreground=None, column_titles=None)[source]

Set a column in the model to be used as either the background or foreground RGBA color for a cell.

Parameters
  • background (int) – The column id of the model to use as the background color.

  • foreground (int) – The column id of the model to use as the foreground color.

  • column_titles (str, tuple) – The columns to set the color for, if None is specified all columns will be set.

set_column_titles(column_titles, column_offset=0, renderers=None)[source]

Populate the column names of a GTK TreeView and set their sort IDs. This also populates the column_titles attribute.

Parameters
  • column_titles (list) – The titles of the columns.

  • column_offset (int) – The offset to start setting column names at.

  • renderers (list) – A list containing custom renderers to use for each column.

Returns

A dict of all the Gtk.TreeViewColumn objects keyed by their column id.

Return type

dict

treeview[source]

The Gtk.TreeView instance being managed.