class documentation

class InputForm(Gtk.Table): (source)

View In Hierarchy

This class implements a table with input widgets. It takes care of constructing the widgets and lay them out as a well formatted input form.

This class can be accessed as a dict to get and set the values of the various input widgets by name. This makes it more or less transparent when getting and setting values from the form into the config or preferences.

Unknown Field: signal
last-activated (): this signal is emitted when the last widget in the form is activated, can be used to trigger a default response in a dialog.
input-valid-changes (): valid state the form changed
Method __contains__ Undocumented
Method __getitem__ Undocumented
Method __init__ Constructor.
Method __iter__ Undocumented
Method __setitem__ Undocumented
Method add_inputs Add input widgets to the form.
Method copy Copy the values of all widgets in the form into a normal dict @returns: a dict with widget values
Method depends No summary
Method focus_first Focus the first widget in the form
Method focus_next Focus the next input in the form
Method get_input_valid Get combined state of all sensitive widgets in the form @returns: True if all sensitive widgets have a valid input
Method items Undocumented
Method keys Undocumented
Method on_activate_widget Undocumented
Method set_default_activate No summary
Method update No summary
Class Variable __gsignals__ Undocumented
Instance Variable notebook the Notebook object, used e.g. for completion in PageEntry inputs
Instance Variable widgets a dict with the input widgets by name. Use this to access the widgets directly (e.g. to wire more signals).
Method _check_input_valid Undocumented
Method _focus_next Undocumented
Method _get_radiogroup Undocumented
Instance Variable _default_activate Undocumented
Instance Variable _input_valid Undocumented
Instance Variable _keys Undocumented
Instance Variable _widgets Undocumented
def __contains__(self, key): (source)

Undocumented

def __getitem__(self, key): (source)

Undocumented

def __init__(self, inputs=None, values=None, depends=None, notebook=None): (source)
Constructor.
Parameters
inputslist with input definitions, see add_inputs() for details
valuesinitial values for the inputs
dependsdict with dependencies between widgets, see depends() for details
notebooka Notebook object, e.g. for completion in PageEntry inputs
def __iter__(self): (source)

Undocumented

def __setitem__(self, key, value): (source)

Undocumented

def add_inputs(self, inputs): (source)

Add input widgets to the form.

Inputs are defined by 3-tuples or 4-tuples of:

  • The input name
  • The input type
  • The label to put in front of the input field
  • optional extra argument

The following input types are supported:

  • "bool" - True or False (checkbox)
  • "int" - integer (spin button)
  • "string" - text entry (InputEntry)
  • "password" - text entry with chars hidden (InputEntry)
  • "page" - a page Path (PageEntry)
  • "namespace" - a namespace Path (NamespaceEntry)
  • "link" - a link as string (LinkEntry)
  • "dir" - a Folder object (FolderEntry)
  • "file" - a File object for an existing file (FileEntry)
  • "image" - like 'file' but specific for images
  • "output-file" - like 'file' but for new or existing file
  • "option" - single option in a group (radio checkboxes)
  • "choice" - list with choices (combo box)
  • "color" - color string

The "int" and "choice" options need an extra argument to specify the allowed inputs. For "int" this should be a 2-tuple with the minimum and maximum values. For 'choice' it should be a tuple or list with the items to choose from. If the items in the list are 2-tuples they are considered pairs of a key and a user readable label.

The input type "option"' can be used to have groups of checkboxes. In this case the name should exist of two parts separated by a ':', first part is the group name and the second part the key for this option. This way multiple options of the same group can be specified as separate widgets. Only the group name will show up as a key in the form, and the value will be the option name of the selected radio button. So you can have names like "select:all" and "select:page" which will result in two radiobuttons. The form will have a key "select" which has either a value "all" or a value "page".

The "page", "namespace" and "link" types support an optional extra argument which gives the reference Path for resolving relative paths. This also requires the notebook to be set.

A string in the input list will result in a label in the form, using markup.

A None or '' value in the input list will result in additional row spacing in the form.

def copy(self): (source)
Copy the values of all widgets in the form into a normal dict
Returns
a dict with widget values
def depends(self, subject, object): (source)

Make one of the inputs depend on another widget. This means that e.g. the "subject" widget will become insensitive when the "object" widget is made insensitive. Also hiding the "object" will result in the "subject" being hidden as well.

If the "object" has an active state (e.g. if it is an checkbox or a radio option) the "subject" will only be sensitive when the "object" is active. This is useful e.g. when you want a text input that is only sensitive when a specific radio box is selected.

Parameters
subjectthe name of the subject widget
objectthe name of the object widget
def focus_first(self): (source)
Focus the first widget in the form
def focus_next(self): (source)
Focus the next input in the form
def get_input_valid(self): (source)
Get combined state of all sensitive widgets in the form
Returns
True if all sensitive widgets have a valid input
def items(self): (source)

Undocumented

def keys(self): (source)

Undocumented

def on_activate_widget(self, widget): (source)

Undocumented

def set_default_activate(self, name): (source)
Mark a widget as the default activation widget. This will cause the "last-activated" signal to be triggered for this widget even if it is not the last widget in the form.
Parameters
namethe name or None
def update(self, map): (source)
Update the value for any existing widget to the value given in map. Unkown keys in map are ignored and widgets that do not have a value in map keep their original value.
Parameters
mapa dict with new values for the widgets
__gsignals__ = (source)

Undocumented

notebook = (source)
the Notebook object, used e.g. for completion in PageEntry inputs
widgets: dict = (source)
a dict with the input widgets by name. Use this to access the widgets directly (e.g. to wire more signals).
def _check_input_valid(self, *a): (source)

Undocumented

def _focus_next(self, widget, activatable=False): (source)

Undocumented

def _get_radiogroup(self, name): (source)

Undocumented

_default_activate = (source)

Undocumented

_input_valid = (source)

Undocumented

_keys: list = (source)

Undocumented

_widgets: list = (source)

Undocumented