dip.ui

The dip.ui module contains a collection of classes that allow a PyQt user interface, or just a part of a user interface, to be defined declaratively.

A user interface is declared as a hierachy of views that are containers for :term`editor` factories and other views. A particular view will arrange its editors or sub-views in a certain way. An editor allows a particular attribute of a model to be displayed and possibly updated.

Editors are testable, i.e. they can be controlled programmatically to simulate the actions of a user so that user interfaces can be automatically tested to ensure that the underlying model is changes as expected.

Views may also include ordinary Qt widgets and layouts and designs created with Qt Designer. Views may also be treated as ordinary Qt widgets and layouts in a larger user interface.

It is not the intention to enable any user interface to be defined declaratively, or to provide the same level of control provided by PyQt itself. The purpose of this module is to allow “boring” user interfaces (e.g. those used for data entry) to be created very easily, or to provide an initial user interface that will be replaced by something more specific at a later stage of an application’s development.

Action

class dip.ui.Action

Base class: Model

The Action class implements an action implemented, by default, as a QAction.

parent = Instance(QObject)
The optional parent.
triggered = Callable()
The callable invoked when the action is triggered.

ActionCollection

class dip.ui.ActionCollection

Base class: Model

The ActionCollection class represents a collection of actions or sub-collections.

members = List(Instance(IAction, str))
The members of the collection. A string is the identifier of an action and is a placeholder for it.
title = Str()
The optional text to be used in any visualisation of the collection. A collection without a title may be visualised differently to one with a title.

AddButton

class dip.ui.AddButton

Base class: LinkedViewFactory

The AddButton class implements a factory for a button for adding to a collection editor.

id_suffix = '.add'
The suffix to add to the identifier to distinguish it from other linked views.
create_view(controller, toolkit, parent)

Create the view.

Parameters:
  • controller – is the controller.
  • toolkit – is the IToolkit implementation used to create the view.
  • parent – is the optional parent widget.
Returns:

the view which will be an instance of QAbstractButton.

This is reimplemented to link the button view to the collection editor.

Parameters:
  • view – is the view.
  • editor – is the editor.

BaseEditorAdapter

class dip.ui.BaseEditorAdapter

Base class: BaseViewAdapter

The BaseEditorAdapter class is a base class for adapters than implement the IEditor interface for Qt widgets.

change_signal = Any()
The Qt signal that is emitted when the user changes the editor’s value.
configure()
Configure the view. This is called when everything else has been set up.
remove_label()
Remove an editor’s label. This will only be called if the label policy is ‘optional’. This default implementation does nothing.

BaseMenu

class dip.ui.BaseMenu

Base class: QObjectFactory

The BaseMenu class is a base class for action containers, i.e. those that implement QMenuBar or QMenu.

classmethod add(item, widget, toolkit, within='', before='')

An IAction or a QMenu is added to a menu bar, menu or a sub-menu.

If an existing item has the same identifier as the item being added then the existing item will be replaced with the new item.

Parameters:
  • item – is the IAction or QMenu to insert.
  • widget – is the menu bar or menu.
  • toolkit – is the toolkit.
  • within – is the identifier of the action collection or menu that the item will be added to. If it is empty then the item will be added to the widget itself.
  • before – is the identifier of the existing item that the item is inserted immediately before. An exception is raised if there is no such existing item. If the identifier is empty then the item will be added at the end of the containing widget.

BaseToolkit

class dip.ui.BaseToolkit

Base class: Model

The BaseToolkit class is a base class for toolkits that implements the default mapping of dip.model types to the editors used to handle them.

Bool_editor_factory = Subclass(EditorFactory)
The editor factory to handle the Bool type.
Bool_delegate_factory = Subclass(EditorFactory)
The delegate editor factory to handle the Bool type.
Enum_editor_factory = Subclass(EditorFactory)
The editor factory to handle the Enum type.
Enum_delegate_factory = Subclass(EditorFactory)
The delegate editor factory to handle the Enum type.
Float_editor_factory = Subclass(EditorFactory)
The editor factory to handle the Float type.
Float_delegate_factory = Subclass(EditorFactory)
The delegate editor factory to handle the Float type.
Int_editor_factory = Subclass(EditorFactory)
The editor factory to handle the Int type.
Int_delegate_factory = Subclass(EditorFactory)
The delegate editor factory to handle the Int type.
List_editor_factory = Subclass(EditorFactory)
The editor factory to handle the List type.
Str_editor_factory = Subclass(EditorFactory)
The editor factory to handle the Str type.
Str_delegate_factory = Subclass(EditorFactory)
The delegate editor factory to handle the Str type.
Trigger_editor_factory = Subclass(EditorFactory)
The editor factory to handle the Trigger type.
delegate_for_attribute(attribute_type)

Return an EditorFactory type object that will create a delegate factory to handle attributes of a particular type.

Parameter:attribute_type – is the type of the attribute.
Returns:the type object.
editor_for_attribute(attribute_type)

Return an EditorFactory type object that will create an editor factory to handle attributes of a particular type.

Parameter:attribute_type – is the type of the attribute.
Returns:the type object.

BaseValidator

class dip.ui.BaseValidator

Base class: QValidator

The BaseValidator class is a base class for a QValidator that supplies a reason why the input is invalid. The reason is saved in the dip_invalid_reason attribute after validate() method is called.

__init__(parent=None)

Initialise the validator.

Parameter:parent – is the optional parent object.

BaseViewAdapter

class dip.ui.BaseViewAdapter

Base class: Adapter

The BaseViewAdapter class is a base class for adapters than implement the IView interface for Qt layouts and widgets.

configure()
Configure the view. This is called when everything else has been set up. This default implementation applies the factory properties to the adaptee.

Bindings

class dip.ui.Bindings

The Bindings class represents set of bindings between widgets of a user interface and attributes of a model.

__init__(**bindings)

Initialise the bindings.

Parameter:**bindings – the bindings specified as keyword arguments. The argument name is the object name of the widget that the attribute will be bound to. The argument value is the binding. If the argument value is a string then an EditorFactory instance will be automatically created for it.
bind(view, model, toolkit, controller=None)

Bind a view to a model.

Parameters:
  • view – is the view.
  • model – is the model which is either a Model instance or a Python mapping object.
  • toolkit – is the IToolkit implementation used to create the view.
  • controller – is the optional controller. A new Controller instance will be created if necessary.

BoxLayoutFactory

class dip.ui.BoxLayoutFactory

Base class: LayoutFactory

The BoxLayoutFactory class is the base class for all factories that create views that are implemented as QBoxLayout instances.

create_additional_content(content)

Create additional content to be added to the list of sub-views.

Parameter:content – the content from which additional content can be created.
Returns:the additional content.

CheckBox

class dip.ui.CheckBox

Base class: EditorFactory

The CheckBox class implements a check box editor factory for bool attributes.

view_interface = ICheckBoxEditor
The specific interface that the view implements.
create_editor(attribute_type, toolkit, parent)

Create the editor.

Parameters:
  • attribute_type – the type of the attribute the factory is being asked to handle. It should be a Bool.
  • toolkit – is the IToolkit implementation used to create the editor.
  • parent – is the optional parent widget.
Returns:

the editor.

CollectionButtons

class dip.ui.CollectionButtons

Base class: HBox

The CollectionButtons class contains the standard buttons used to manipulate a collection editor. Use the buttons separately if you want to lay them out differently.

__init__(linked_to, **properties)

Initialise the item.

Parameters:
  • linked_to – is the identifier of the editor that each button is linked to.
  • **properties – are keyword arguments used as property names and values that are applied to the view.

ComboBox

class dip.ui.ComboBox

Base class: EditorFactory

The ComboBox class implements a combo box editor factory for enum attributes.

view_interface = IComboBoxEditor
The specific interface that the view implements.
create_editor(attribute_type, toolkit, parent)

Create the editor.

Parameters:
  • attribute_type – the type of the attribute the factory is being asked to handle. It should be an Enum.
  • toolkit – is the IToolkit implementation used to create the editor.
  • parent – is the optional parent widget.
Returns:

the editor.

CompositeViewFactory

class dip.ui.CompositeViewFactory

Base class: ViewFactory

The CompositeViewFactory class is the base factory class for all views that can contain sub-views. A sub-class determines the layout of the sub-views.

view_interface = ICompositeView
The specific interface that the view implements.
__init__(*contents, **properties)

Initialise the view.

Parameters:
  • *contents – is the list of the view’s contents. An individual item can either be a ViewFactory instance or a string. Strings are are assumed to be the names of attributes within a model. Such names may include one or more periods to specify an attribute path.
  • **properties – are keyword arguments used as property names and values that are applied to the view.
create_additional_content(content)

Create additional content to be added to the list of sub-views. This default implementation will always raise an exception.

Parameter:content – the content from which additional content can be created.
Returns:the additional content.
create_subviews(controller, toolkit, parent)

Return a list of QLayout and QWidget instances that implement the sub-views. A sub-class may include additional contents of different types, but these must be able to be handled by the view that the factory creates.

Parameters:
  • controller – is the controller.
  • toolkit – is the IToolkit implementation used to create the view.
  • parent – is the optional parent widget.
Returns:

the list of QLayout and QWidget instances.

finalize(item)

Reimplemented to finalize all sub-views.

Parameter:item – is the view created by this factory.

Controller

class dip.ui.Controller

Base class: Model

The Controller class is the default implementation of a controller.

__getattr__(name)
Reimplemented to get an instance attribute allowing for names in the form ‘id_editor’ where ‘id’ is the identifier of the editor.
add_editor(editor)

Add an editor to the controller.

Parameter:editor – is the editor.
editor_changed(editor)

This is called by an editor when the user has changed its value.

Parameter:editor – is the editor.
find_editor(id)

Find the editor with a specific identifier.

Parameter:id – is the identifier of the editor.
Returns:the editor or None if the view has no such editor.
update_model()
Update the all the attributes of a model that have a corresponding editor.
validate()
Validate the view and update the explanation as to why it is (or isn’t) invalid.
validate_view()

Validate the data in the view. This implementation considers the view to be valid if all its editors have valid values.

Returns:a string which will be empty if the view is valid, otherwise it will explain why the view is invalid.

Designer

class dip.ui.Designer

Base class: ViewFactory

The Designer class allows any user interface created with Qt Designer to be used in a view.

bindings = Instance(Bindings)
The bindings that connect the GUI to the model.
ui_file_name = Str()
The name of the Qt Designer .ui file.
__init__(ui_file_name, **properties)

Initialise the item.

Parameters:
  • ui_file_name – is the name of the Qt Designer .ui file.
  • **properties – are keyword arguments used as property names and values that are applied to the widget.
create_subview(controller, toolkit, attribute_type)

Create the editor for the user interface.

Parameters:
  • controller – is the controller.
  • toolkit – is the IToolkit implementation.
  • parent – is the optional parent widget.
  • attribute_type – is None in this context.
Returns:

the editor that is the root of the user interface defined in the .ui file.

create_view(controller, toolkit, parent)

Create the editor for the user interface.

Parameters:
  • controller – is the controller.
  • toolkit – is the IToolkit implementation.
  • parent – is the optional parent widget.
Returns:

the editor that is the root of the user interface defined in the .ui file.

Dialog

class dip.ui.Dialog

Base class: SingleSubviewFactory

The Dialog class implements a QDialog based dialog.

buttons = Instance(QDialogButtonBox.StandardButtons)
The buttons to display.
create_controller()

Create an implementation of IController.

Returns:the controller.
create_view(controller, toolkit, parent)

Create the view.

Parameters:
  • controller – is the controller.
  • toolkit – is the IToolkit implementation used to create the view.
  • parent – is the optional parent widget.
Returns:

the QLayout or QWidget that is the root of the view’s implementation.

DirectoryValidator

class dip.ui.DirectoryValidator

Base class: BaseValidator

The DirectoryValidator class is a validator that checks that the input is the name of an existing directory.

validate(input, pos)

Validate the input.

Parameters:
  • input – is the input to validate.
  • pos – is the current position within the input.
Returns:

a 3-tuple of the state, possibly modified input and possibly modified position.

DownButton

class dip.ui.DownButton

Base class: LinkedViewFactory

The DownButton class implements a factory for a button for moving an item down a collection editor.

id_suffix = '.down'
The suffix to add to the identifier to distinguish it from other linked views.
create_view(controller, toolkit, parent)

Create the view.

Parameters:
  • controller – is the controller.
  • toolkit – is the IToolkit implementation used to create the view.
  • parent – is the optional parent widget.
Returns:

the view which will be an instance of QAbstractButton.

This is reimplemented to link the button view to the collection editor.

Parameters:
  • view – is the view.
  • editor – is the editor.

EditorFactory

class dip.ui.EditorFactory

Base class: ViewFactory

The EditorFactory class is a factory for views that implement the IEditor interface.

bind_to = Str()
The name of the attribute that the editor is bound to. This may be an attribute path.
default_metadata_properties = List(Str(), default=['statusTip', 'toolTip', 'whatsThis'])
The default list of Qt properties that should be set for the editor with the values taken from the model attribute’s meta-data.
extra_metadata_properties = List(Str())
The list of extra Qt properties that should be set for the editor with the values taken from the model attribute’s meta-data.
label = Str()
A short, user friendly label for the attribute. It is typically used as a field name or the text of a push button. If not given then the label value of the type’s meta-data is used instead. If that hasn’t been defined then a label based on the name of the attribute in its containing model is used.
read_only = Bool(False)
This is set if the attribute is read-only.
__init__(bind_to='', **properties)

Initialise the factory.

Parameters:
  • bind_to – the name of the attribute that the editor is bound to. It should only be an empty string if the factory is being used to create a delegate.
  • **properties – are keyword arguments used as property names and values that are applied to the editor.
bind(view, controller, toolkit, attribute_type)

Reimplemented to bind an editor view to a model attribute and add it to a controller.

Parameters:
  • view – is the view.
  • controller – is the controller.
  • toolkit – is the IToolkit implementation used to create the view.
  • attribute_type – is the type of the attribute of a model the view is being bound to.
configure_editor(editor, attribute_type)

Configure an editor using the factory’s properties and any additional properties supplied when the factory was created.

Parameters:
  • editor – is the editor. Note that this isn’t necessarily the IEditor implementation but may be an internal widget that the properties are to be applied to.
  • attribute_type – is the type of the attribute in the model the editor is bound to.
create_editor(attribute_type, toolkit, parent)

Create the QLayout or QWidget that implements the editor and can be adapted to IEditor.

This must be reimplemented by a sub-class.

Parameters:
  • attribute_type – is the type of the attribute in the model that the editor is bound to.
  • toolkit – is the IToolkit implementation used to create the editor.
  • parent – is the optional parent widget.
Returns:

the QLayout or QWidget that is the root of the editor’s implementation.

create_view(controller, toolkit, parent)

Create the view.

Parameters:
  • controller – is the controller.
  • toolkit – is the IToolkit implementation used to create the view.
  • parent – is the optional parent widget.
Returns:

the view.

classmethod editor_as_delegate(delegate_type, toolkit)

Create an editor factory to be used as a delegate for a type.

Parameters:
  • delegate_type – is the type of the value that the delegate will edit.
  • toolkit – is the IToolkit implementation that provides the mapping between types and delegates.
Returns:

the editor factory.

get_attribute_label(attribute_type)

Get the label for an attribute. This will first try the factory itself, then the type’s meta-data and finally the type’s name.

Parameter:attribute_type – is the attribute type.
Returns:the label.
classmethod get_natural_name(name)

Convert a name, typically of an attribute, to a more natural name.

Parameter:name – is the original name.
Returns:the more natural version.
set_delegate(item_view, delegate_type, toolkit, column_nr=0)

Create a delegate and set it for a column of a QAbstractItemView.

Parameters:
  • item_view – is the QAbstractItemView.
  • delegate_type – is the type of the value that the delegate will edit.
  • column_nr – is the number of the column.
  • toolkit – is the IToolkit implementation used to create the editor.

FileSelector

class dip.ui.FileSelector

Base class: EditorFactory

The FileSelector class implements a file (and directory) selector editor factory.

filter = Str()
The filter string in the format used by QFileDialog.
mode = Enum('open_file', 'save_file', 'directory')
The mode of the file selector. ‘open_file’ means a single, existing file will be obtained. ‘save_file’ means that a single file that may or may not exist will be obtained. ‘directory’ means a single, existing directory will be obtained.
validator = Callable()
The validator factory. This is called and passed a parent QObject and should return a QValidator instance. If mode is ‘open_file’ then the default is FileValidator. If it is ‘directory’ then the default is DirectoryValidator.
view_interface = IFileSelectorEditor
The specific interface that the view implements.
create_editor(attribute_type, toolkit, parent)

Create the editor.

Parameters:
  • attribute_type – the type of the attribute the factory is being asked to handle. It should be a Str.
  • toolkit – is the IToolkit implementation used to create the editor.
  • parent – is the optional parent widget.
Returns:

the editor.

FileValidator

class dip.ui.FileValidator

Base class: BaseValidator

The FileValidator class is a validator that checks that the input is the name of an existing file.

validate(input, pos)

Validate the input.

Parameters:
  • input – is the input to validate.
  • pos – is the current position within the input.
Returns:

a 3-tuple of the state, possibly modified input and possibly modified position.

FloatSpinBox

class dip.ui.FloatSpinBox

Base class: EditorFactory

The FloatSpinBox class implements a spin box editor factory for float attributes.

extra_metadata_properties = ['maximum', 'minimum']
Extra properties set from the attribute’s metadata.
view_interface = IFloatSpinBoxEditor
The specific interface that the view implements.
create_editor(attribute_type, toolkit, parent)

Create the editor.

Parameters:
  • attribute_type – the type of the attribute the factory is being asked to handle. It should be a Float.
  • toolkit – is the IToolkit implementation used to create the editor.
  • parent – is the optional parent widget.
Returns:

the editor.

Form

class dip.ui.Form

Base class: LayoutFactory

The Form class arranges its contents as a form.

create_layout(items, toolkit)

Create a layout for a form sub-view.

Parameters:
  • toolkit – is the IToolkit implementation used to create the horizontal box layout.
  • attribute_type – is None in this context.
Returns:

the QLayout instance that is the view’s implementation.

GroupBox

class dip.ui.GroupBox

Base class: SingleSubviewFactory

The GroupBox class arranges its contents in a group box.

create_view(controller, toolkit, parent)

Create the view.

Parameters:
  • controller – is the controller.
  • toolkit – is the IToolkit implementation used to create the view.
  • parent – is the optional parent widget. It is ignored in this context.
Returns:

the QLayout or QWidget that is the root of the view’s implementation.

HBox

class dip.ui.HBox

Base class: BoxLayoutFactory

The HBox class arranges its contents horizontally.

create_layout(items, toolkit)

Create a layout for a horizontal sub-view.

Parameters:
  • items – is a sequence of QLayout, QWidget and Stretch instances.
  • toolkit – is the IToolkit implementation used to create the layout.
Returns:

the layout.

IAction

class dip.ui.IAction

Base class: Interface

The IAction interface defines the API for an action that can be identified and positioned relative to another.

before = Str()
The identifier of the action before which this action will be placed.
id = Str()
The identifier of the action.
within = Str()
The identifier of action in which this action will be placed.

ICheckBoxEditor

class dip.ui.ICheckBoxEditor

Base class: IEditor

The ICheckBoxEditor interface defines the API to be implemented by an editor created by CheckBox. It is used as a marker to ensure the correct adapter is chosen.

ICollectionEditor

class dip.ui.ICollectionEditor

Base class: IEditor

The ICollectionEditor interface defines the API to be implemented (typically using adaptation) by an editor created by an EditorFactory that handles a collection type (e.g. a list).

item_count = Int()
The number of items in the collection. This can only be read.
selection = List(QModelIndex)
The current selection.
add(value=None, edit=True)

Add a new item to the collection.

Parameters:
  • value – is the value of the item. If it is None then an appropriate value will be created automatically.
  • edit – is set if an editor should be open automatically for the new item.
item_invalid_reason(index, invalid_reason)

Update the invalid reason for an item in the collection.

Parameters:
  • index – is the QModelIndex of the item.
  • index – is the invalid reason. It will be an empty string if the item is valid.
move_down(index)

Move an item down.

Parameter:index – is the QModelIndex of the item.
move_up(index)

Move an item up.

Parameter:index – is the QModelIndex of the item.
remove(indexes)

Remove a number of items from the collection.

Parameter:indexes – is the list of QModelIndex defining the items to be removed.

IComboBoxEditor

class dip.ui.IComboBoxEditor

Base class: IEditor

The IComboBoxEditor interface defines the API to be implemented by an editor created by ComboBox. It is used as a marker to ensure the correct adapter is chosen.

ICompositeView

class dip.ui.ICompositeView

Base class: IView

The ICompositeView interface defines the API to be implemented (typically using adaptation) by a QLayout or QWidget created by a CompositeViewFactory.

subviews()

Return a sequence of sub-views, i.e. instances of QLayout or QWidget that implement or have been adapted to IView.

Returns:the sequence of sub-views.

IController

class dip.ui.IController

Base class: Interface

The IController interface defines the API to be implemented by a view’s controller.

auto_update_model = Bool(True)
This determines if the controller should automatically update the model when the user changes the value of an editor (and the controller determines that the view is valid).
invalid_reason = Str()
This explains why the view is invalid. It will be an empty string if the view is valid.
message_areas = List(IMessageArea)
The message areas for giving feedback to the user.
model = Instance(Model)
The model.
view = Instance(QLayout, QWidget)
The view.
__getattr__(name)
Reimplemented to get an instance attribute allowing for names in the form ‘attr_editor’ where ‘attr’ is the name of a model attribute.
add_editor(editor)

Add an editor to the controller.

Parameter:editor – is the editor.
editor_changed(editor)

This is called by an editor when the user has changed its value.

Parameter:editor – is the editor.
find_editor(id)

Find the editor with a specific identifier.

Parameter:id – is the identifier of the editor.
Returns:the editor or None if the view has no such editor.
update_model()
Update the all the attributes of a model that have a corresponding editor.
validate()
Validate the view and update the explanation as to why it is (or isn’t) invalid.
validate_view()

Validate the data in the view.

Returns:a string which will be empty if the view is valid, otherwise it will explain why the view is invalid.

IEditor

class dip.ui.IEditor

Base class: IView

The IEditor interface defines the API to be implemented (typically using adaptation) by a QWidget created by an EditorFactory.

enabled = Bool(True)
This is set if the editor is enabled.
invalid_reason = Str()
This explains why the editor is invalid. It will be an empty string if the editor is valid.
label = Str()
The editor’s label. This is typically used in a form layout and in error messages.
label_policy = Enum('default', 'optional', 'embedded')
The policy a view should follow when handling the editor’s label. ‘default’ means that the editor doesn’t embed the label and the view is free to use it in any way. ‘optional’ means the editor embeds the label but the view can ask for it to be removed. ‘embedded’ means the editor embeds the label and the view cannot do anything with it.
attribute_type = Instance(TypeFactory)
The type of the attribute in the model.
value = Any()
The value of the editor.
remove_label()
Remove an editor’s label. This will only be called if the label policy is ‘optional’.

IFileSelectorEditor

class dip.ui.IFileSelectorEditor

Base class: IEditor

The IFileSelectorEditor interface defines the API to be implemented by an editor created by FileSelector. It is used as a marker to ensure the correct adapter is chosen.

IFloatSpinBoxEditor

class dip.ui.IFloatSpinBoxEditor

Base class: IEditor

The IFloatSpinBoxEditor interface defines the API to be implemented by an editor created by FloatSpinBox. It is used as a marker to ensure the correct adapter is chosen.

ILineEditEditor

class dip.ui.ILineEditEditor

Base class: IEditor

The ILineEditEditor interface defines the API to be implemented by an editor created by LineEdit. It is used as a marker to ensure the correct adapter is chosen.

IListWidgetEditor

class dip.ui.IListWidgetEditor

Base class: ICollectionEditor

The IListWidgetEditor interface defines the API to be implemented by an editor created by ListWidget. It is used as a marker to ensure the correct adapter is chosen.

IMessageArea

class dip.ui.IMessageArea

Base class: IView

The IMessageArea interface defines the API to be implemented by a view that is used as a message area and created by a MessageArea.

text = Str()
The text displayed in the message area.

IPushButtonEditor

class dip.ui.IPushButtonEditor

Base class: IEditor

The IPushButtonEditor interface defines the API to be implemented by an editor created by PushButton. It is used as a marker to ensure the correct adapter is chosen.

IQActionAction

class dip.ui.IQActionAction

Base class: IAction

The IQActionAction interface defines the API for an action that is implemented as a QAction.

action = Instance(QAction)
The QAction that is the actual action.
shortcut = Instance(QKeySequence, QKeySequence.StandardKey, str)
The action’s shortcut.
statusTip = Str()
The action’s status tip. The naming convention is to maintain compatibility with the standard QAction property.
text = Str()
The action’s text.
toolTip = Str()
The action’s tool tip. The naming convention is to maintain compatibility with the standard QAction property.

IRadioButtonsEditor

class dip.ui.IRadioButtonsEditor

Base class: IEditor

The IRadioButtonsEditor interface defines the API to be implemented by an editor created by RadioButtons. It is used as a marker to ensure the correct adapter is chosen.

ISpinBoxEditor

class dip.ui.ISpinBoxEditor

Base class: IEditor

The ISpinBoxEditor interface defines the API to be implemented by an editor created by SpinBox. It is used as a marker to ensure the correct adapter is chosen.

ITableWidgetEditor

class dip.ui.ITableWidgetEditor

Base class: ICollectionEditor

The ITableWidgetEditor interface defines the API to be implemented by an editor created by TableWidget. It is used as a marker to ensure the correct adapter is chosen.

ITextEditEditor

class dip.ui.ITextEditEditor

Base class: IEditor

The ITextEditEditor interface defines the API to be implemented by an editor created by TextEdit. It is used as a marker to ensure the correct adapter is chosen.

IToolButtonEditor

class dip.ui.IToolButtonEditor

Base class: IEditor

The IToolButtonEditor interface defines the API to be implemented by an editor created by ToolButton. It is used as a marker to ensure the correct adapter is chosen.

IToolkit

class dip.ui.IToolkit

Base class: Interface

The IToolkit interface defines the API to be implemented by a toolkit.

add_button(factory, parent)

Create a button to add an item to a collection.

Parameters:
  • factory – is the factory creating the button.
  • parent – is the optional parent widget.
Returns:

the button which will be a QAbstractButton.

check_box(factory, attribute_type, parent)

Create an editor based on a check box.

Parameters:
  • factory – is the factory creating the editor.
  • attribute_type – is the attribute type.
  • parent – is the parent widget.
Returns:

the editor.

combo_box(factory, attribute_type, parent)

Create an editor based on a combo box.

Parameters:
  • factory – is the factory creating the editor.
  • attribute_type – is the attribute type.
  • parent – is the parent widget.
Returns:

the editor.

delegate_for_attribute(attribute_type)

Return an EditorFactory type object that will create a delegate factory to handle attributes of a particular type.

Parameter:attribute_type – is the type of the attribute.
Returns:the type object.
dialog(factory, content, parent)

Create a dialog view.

Parameters:
  • factory – is the factory creating the view.
  • content – is the content of the dialog and is either a QLayout or a QWidget.
  • parent – is the optional parent widget.
Returns:

the view.

down_button(factory, parent)

Create a button to move an item in a collection down.

Parameters:
  • factory – is the factory creating the button.
  • parent – is the optional parent widget.
Returns:

the button which will be a QAbstractButton.

editor_for_attribute(attribute_type)

Return an EditorFactory type object that will create an editor factory to handle attributes of a particular type.

Parameter:attribute_type – is the type of the attribute.
Returns:the type object.
editor_for_widget(widget_type)

Return an EditorFactory type object that will create an editor factory that creates editors of a particular type.

Parameter:widget_type – is the type of the widget.
Returns:the type object.
file_selector(factory, attribute_type, parent)

Create an editor that implements a file/directory selector.

Parameters:
  • factory – is the factory creating the editor.
  • attribute_type – is the attribute type.
  • parent – is the parent widget.
Returns:

the editor.

float_spin_box(factory, attribute_type, parent)

Create an editor for floats based on a spin box.

Parameters:
  • factory – is the factory creating the editor.
  • attribute_type – is the attribute type.
  • parent – is the parent widget.
Returns:

the editor.

form(factory, items)

Create a view to contain a number of items arranged as a form.

Parameters:
  • factory – is the optional factory creating the view.
  • items – is a sequence of 2-tuple label and field pairs. A label may be None. A field may be a QLayout or a QWidget.
Returns:

the view.

get_directory(directory='', parent=None)

Get the name of an existing directory from the user.

Parameters:
  • directory – is the name of an optional initial directory.
  • parent – is the optional parent widget.
Returns:

the name of the directory or an empty string if there was none.

get_open_file(directory='', filter='', parent=None)

Get the name of a file to open from the user.

Parameters:
  • directory – is the name of an optional initial directory or file.
  • filter – is the optional file filter.
  • parent – is the optional parent widget.
Returns:

the name of the file to open or an empty string if there was none.

get_open_files(directory='', filter='', parent=None)

Get a list of names of files to open from the user.

Parameters:
  • directory – is the name of an optional initial directory or file.
  • filter – is the optional file filter.
  • parent – is the optional parent widget.
Returns:

the list of names.

get_save_file(directory='', filter='', parent=None)

Get the name of a file to save from the user.

Parameters:
  • directory – is the name of an optional initial directory or file.
  • filter – is the optional file filter.
  • parent – is the optional parent widget.
Returns:

the name of the file to save or an empty string if there was none.

group_box(factory, content, parent)

Create a group box view.

Parameters:
  • factory – is the factory creating the view.
  • content – is the content of the view and is either a QLayout or a QWidget.
  • parent – is the optional parent widget.
Returns:

the view.

h_box(factory, items)

Create a view to contain a number of items arranged horizontally.

Parameters:
  • factory – is the factory creating the view.
  • items – is a sequence of QLayout, QWidget and Stretch instances.
Returns:

the view.

information(title, text, parent=None)

Display a informational message to the user.

Parameters:
  • title – is the title, typically used as the title of a dialog.
  • text – is the text of the message.
  • parent – is the optional parent widget.
line_edit(factory, attribute_type, parent)

Create an editor based on a line editor.

Parameters:
  • factory – is the factory creating the editor.
  • attribute_type – is the attribute type.
  • parent – is the parent widget.
Returns:

the editor.

list_widget(factory, attribute_type, parent)

Create an editor for a list.

Parameters:
  • factory – is the factory creating the editor.
  • attribute_type – is the attribute type.
  • parent – is the parent widget.
Returns:

the editor.

menu(title, parent)

Create a menu.

Parameters:
  • title – is the menu’s title.
  • parent – is the menu’s parent.
Returns:

the menu which will be an instance of QMenu.

menu_bar()

Create a menu bar.

Returns:the menu bar which will be an instance of QMenuBar.
message_area(factory, parent)

Create a message area.

Parameters:
  • factory – is the factory creating the message area.
  • parent – is the optional parent widget.
Returns:

the message area which will be an instance of QLabel.

push_button(factory, attribute_type, parent)

Create an editor based on a push button.

Parameters:
  • factory – is the factory creating the editor.
  • attribute_type – is the attribute type.
  • parent – is the parent widget.
Returns:

the editor.

question(title, text, parent=None, default_no=True)

Ask the user a question with a yes or no answer.

Parameters:
  • title – is the title, typically used as the title of a dialog.
  • text – is the text of the question.
  • parent – is the optional parent widget.
  • default_no – is True if the default answer to the question is “no”.
Returns:

True if the answer was “yes”.

radio_buttons(factory, attribute_type, parent)

Create an editor that implements a set of radio buttons.

Parameters:
  • factory – is the factory creating the editor.
  • attribute_type – is the attribute type.
  • parent – is the parent widget.
Returns:

the editor.

remove_button(factory, parent)

Create a button to add an item to a collection.

Parameters:
  • factory – is the factory creating the button.
  • parent – is the optional parent widget.
Returns:

the button which will be a QAbstractButton.

spin_box(factory, attribute_type, parent)

Create an editor based on a spin box.

Parameters:
  • factory – is the factory creating the editor.
  • attribute_type – is the attribute type.
  • parent – is the parent widget.
Returns:

the editor.

splitter(factory, items)

Create a splitter view to contain a number of items.

Parameters:
  • factory – is the factory creating the view.
  • items – is a sequence of QLayout or QWidget instances.
Returns:

the view.

table_widget(factory, attribute_type, parent)

Create an editor for a table.

Parameters:
  • factory – is the factory creating the editor.
  • attribute_type – is the attribute type.
  • parent – is the parent widget.
Returns:

the editor which will be an instance of QTableWidget. The properties will be applied to the editor itself.

text_edit(factory, attribute_type, parent)

Create an editor based on a text editor.

Parameters:
  • factory – is the factory creating the editor.
  • attribute_type – is the attribute type.
  • parent – is the parent widget.
Returns:

the editor.

tool_button(factory, attribute_type, parent)

Create an editor based on a tool button.

Parameters:
  • factory – is the factory creating the editor.
  • attribute_type – is the attribute type.
  • parent – is the parent widget.
Returns:

the editor.

up_button(factory, parent)

Create a button to move an item in a collection up.

Parameters:
  • factory – is the factory creating the button.
  • parent – is the optional parent widget.
Returns:

the button which will be a QAbstractButton.

v_box(factory, items)

Create a view to contain a number of items arranged vertically.

Parameters:
  • factory – is the factory creating the view.
  • items – is a sequence of QLayout, QWidget and Stretch instances.
Returns:

the view.

warning(title, text, parent=None, detail='')

Display a warning message to the user.

Parameters:
  • title – is the title, typically used as the title of a dialog.
  • text – is the text of the warning.
  • parent – is the optional parent widget.
  • detail – is the optional additional detail.
wizard(factory, pages, parent)

Create a wizard view.

Parameters:
  • factory – is the factory creating the view.
  • pages – is the list of wizard pages.
  • parent – is the optional parent widget.
Returns:

the view.

wizard_page(factory, content, parent)

Create a wizard page view.

Parameters:
  • factory – is the factory creating the view.
  • content – is the content of the view and is either a QLayout or a QWidget.
  • parent – is the optional parent widget.
Returns:

the view.

IView

class dip.ui.IView

Base class: Interface

The IView interface defines the API to be implemented (typically using adaptation) by a QLayout or QWidget created by a ViewFactory.

controller = Instance(dip.ui.IController)
The controller.
factory = Instance(dip.ui.ViewFactory)
The factory that created this view.
toolkit = Instance(IToolkit)
The toolkit that created this view.
configure()
Configure the view. This is called when everything else has been set up.

LayoutFactory

class dip.ui.LayoutFactory

Base class: CompositeViewFactory

The LayoutFactory class is the base class for all factories that create views that are implemented as QLayout instances.

create_layout(items, toolkit)

Create the specific QLayout instance.

This must be reimplemented by a sub-class

Parameters:
  • items – is a sequence of QLayout, QWidget and Stretch instances.
  • toolkit – is the IToolkit implementation used to create the layout.
Returns:

the layout.

create_view(controller, toolkit, parent)

Reimplemented to ensure the view is a QWidget.

Parameters:
  • controller – is the controller.
  • toolkit – is the IToolkit implementation used to create the view.
  • parent – is the optional parent widget.
Returns:

the QWidget that is the root of the view’s implementation.

LineEdit

class dip.ui.LineEdit

Base class: EditorFactory

The LineEdit class implements a line editor editor factory for string attributes.

required = Enum('meta-data', 'no', 'yes', 'stripped')
This specifies whether or not a value is required. It is applied after any validator has determined that the value is valid. ‘meta-data’ means that the behavior is determined by any corresponding attribute in the meta-data of the model type that the factory is bound to. ‘no’ means that a value is not required (i.e. it can be an empty string). ‘yes’ means that a value is required. ‘stripped’ means that a value with no leading or trailing whitespace is required. If ‘meta-data’ is specified, but there is no corresponding meta-data then ‘no’ is assumed.
validator = Any()
The validator which is either a string or a callable. If it is a string then it is assumed to be a Qt regular expression and a QRegExpValidator is created automatically. Otherwise it is called and passed a parent QObject and should return a QValidator instance.
view_interface = ILineEditEditor
The specific interface that the view implements.
create_editor(attribute_type, toolkit, parent)

Create the editor.

Parameters:
  • attribute_type – the type of the attribute the factory is being asked to handle. It should be a Str.
  • toolkit – is the IToolkit implementation used to create the editor.
  • parent – is the optional parent widget.
Returns:

the editor.

LinkedViewFactory

class dip.ui.LinkedViewFactory

Base class: ViewFactory

The LinkedViewFactory class is a base class for factories for views that are linked to editors and, in some way, supplement the behaviour of the editor being linked to.

id_suffix = Str()
The suffix to add to the identifier to distinguish it from other views linked to the same editor.
linked_to = Str()
The identifier of the editor that this view is linked to.
__init__(linked_to, **properties)

Initialise the factory.

Parameters:
  • linked_to – the identifier of the editor that the view is linked to.
  • **properties – are keyword arguments used as property names and values that are applied to the view.
finalize(item)

This is reimplemented to disable the view created by this factory if the linked editor is read-only.

Parameter:item – is the view.

This is normally reimplemented to link the view created by this factory to an editor once everything else has been set up.

Parameters:
  • view – is the view.
  • editor – is the editor.

ListColumn

class dip.ui.ListColumn

Base class: Model

The ListColumn class represents the meta-data of the column of a list.

column_type = Instance(TypeFactory)
The type of the column. It is ignored unless a list element is an Any value.
editor_factory = Instance(EditorFactory)
The factory for the editor created to edit a value in the column. It will default to the editor factory provided by the toolkit for the type of the value.

ListWidget

class dip.ui.ListWidget

Base class: EditorFactory

The ListWidget class implements a list widget editor factory for list attributes.

column = Instance(ListColumn)
The column.
item_factory = Callable()
When called this will create the data for a new item in the list. If a factory isn’t provided then a value based on the default value of the type of the list’s items.
view_interface = IListWidgetEditor
The specific interface that the view implements.
configure_delegate(editor, attribute_type, toolkit)

Configure the delegate for an editor created by the factory.

Parameters:
  • editor – is the editor.
  • attribute_type – is the list’s type.
  • toolkit – is the IToolkit implementation used to create the editor.
configure_widget_item(widget_item, attribute_type)

Configure a new widget item.

Parameters:
  • widget_item – is the widget item, usually a QListWidgetItem instance.
  • attribute_type – is the list’s type.
create_editor(attribute_type, toolkit, parent)

Create the editor.

Parameters:
  • attribute_type – the type of the attribute the factory is being asked to handle. It should be a List.
  • toolkit – is the IToolkit implementation used to create the editor.
  • parent – is the optional parent widget.
Returns:

the editor.

create_item(attribute_type)

Create a new item for the list.

Parameter:attribute_type – is the list’s type.
Returns:the new item.

MessageArea

class dip.ui.MessageArea

Base class: ViewFactory

The MessageArea class is a factory for a message area, which will be an implementation of, or something that be adapted to, IMessageArea to be used by a controller to display messages to the user.

view_interface = IMessageArea
The specific interface that the view implements.
bind(view, controller, toolkit)

Reimplemented to add the message area view to a controller.

Parameters:
  • view – is the view.
  • controller – is the controller.
  • toolkit – is the IToolkit implementation used to create the view.
create_view(controller, toolkit, parent)

Create the view.

Parameters:
  • controller – is the controller.
  • toolkit – is the IToolkit implementation used to create the view.
  • parent – is the optional parent widget.
Returns:

the view.

PushButton

class dip.ui.PushButton

Base class: EditorFactory

The PushButton class implements a push button editor factory for trigger attributes.

extra_metadata_properties = ['icon']
Extra properties set from the attribute’s metadata.
view_interface = IPushButtonEditor
The specific interface that the view implements.
create_editor(attribute_type, toolkit, parent)

Create the editor.

Parameters:
  • attribute_type – the type of the attribute the factory is being asked to handle. It should be a Trigger.
  • toolkit – is the IToolkit implementation used to create the editor.
  • parent – is the optional parent widget.
Returns:

the editor.

QObjectFactory

class dip.ui.QObjectFactory

Base class: Model

The QObjectFactory class is the base class for all factories that can create a QObject whose properties can be configured and that support the concept of an identifier.

id = Str()
The identifier of the item that is created. If it is not specified then a sub-class may implement an appropriate default. The item’s object name will default to the identifier.
__init__(**properties)

Initialize the item.

Parameter:**properties – are keyword arguments used as property names and values that are applied to the QObject instances created by the factory.
__call__()

Create the QObject instance. This should be reimplemented by a sub-class

Returns:the object.
configure_properties(item, properties=None)

Configure an item’s properties.

Parameters:
  • item – is the item whose properties are being set.
  • properties – is the dictionary of property names and values. If it is None then the properties supplied when the factory was created.
finalize(item)

This is called once all similar items have been created. This default implementation will set the item’s object name to the factory’s identifier if it doesn’t already have a name.

Parameter:item – is the item that was created by this factory.

RadioButtons

class dip.ui.RadioButtons

Base class: EditorFactory

The RadioButtons class implements a radio buttons editor factory for enum attributes.

frame = Enum('full', 'flat', 'none')
The style of any frame. ‘full’ is a surrounding frame with the label embeded. ‘flat’ is a partial frame with the label embedded. ‘none’ is no frame.
orientation = Instance(Qt.Orientation, default=Qt.Vertical)
The orientation of the radio buttons.
view_interface = IRadioButtonsEditor
The specific interface that the view implements.
create_editor(attribute_type, toolkit, parent)

Create the editor.

Parameters:
  • attribute_type – the type of the attribute the factory is being asked to handle. It should be an Enum.
  • toolkit – is the IToolkit implementation used to create the editor.
  • parent – is the optional parent widget.
Returns:

the editor.

RemoveButton

class dip.ui.RemoveButton

Base class: LinkedViewFactory

The RemoveButton class implements a factory for a button for removing from a collection editor.

id_suffix = '.remove'
The suffix to add to the identifier to distinguish it from other linked views.
create_view(controller, toolkit, parent)

Create the view.

Parameters:
  • controller – is the controller.
  • toolkit – is the IToolkit implementation used to create the view.
  • parent – is the optional parent widget.
Returns:

the view which will be an instance of QAbstractButton.

This is reimplemented to link the button view to the collection editor.

Parameters:
  • view – is the view.
  • editor – is the editor.

SingleSubviewFactory

class dip.ui.SingleSubviewFactory

Base class: CompositeViewFactory

The SingleSubviewFactory class is a base class for composite views that can only have a single sub-view.

__init__(*contents, **properties)

Initialise the view.

Parameters:
  • *contents – is the list of the view’s contents. An individual item can either be a ViewFactory instance or a string. Strings are are assumed to be the names of attributes within a model. Such names may include one or more periods to specify an attribute path.
  • **properties – are keyword arguments used as property names and values that are applied to the view.

SpinBox

class dip.ui.SpinBox

Base class: EditorFactory

The SpinBox class implements a spin box editor factory for integer attributes.

extra_metadata_properties = ['maximum', 'minimum']
Extra properties set from the attribute’s metadata.
view_interface = ISpinBoxEditor
The specific interface that the view implements.
create_editor(attribute_type, toolkit, parent)

Create the editor.

Parameters:
  • attribute_type – the type of the attribute the factory is being asked to handle. It should be an Int.
  • toolkit – is the IToolkit implementation used to create the editor.
  • parent – is the optional parent widget.
Returns:

the editor.

Splitter

class dip.ui.Splitter

Base class: CompositeViewFactory

The Splitter class arranges its contents in a splitter.

create_view(controller, toolkit, parent)

Create a splitter view.

Parameters:
  • controller – is the controller.
  • toolkit – is the IToolkit implementation used to create the splitter.
  • parent – is the optional parent widget.
Returns:

the QWidget instance that is the view’s implementation.

Stretch

class dip.ui.Stretch

Base class: Model

The Stretch class represents a stretchable space that can be added to a view.

stretch = Int(0)
The stretch factor.

TableColumn

class dip.ui.TableColumn

Base class: Model

The TableColumn class represents the meta-data of a column of a table.

bind_to = Str()
The name of attribute that the column is bound to. It will be empty if a row is a list rather than a model.
column_type = Instance(TypeFactory)
The type of the column. It is ignored unless a row is a list of Any values.
editable = Bool(True)
This is set if the values in the column are editable.
editor_factory = Instance(EditorFactory)
The factory for the editor created to edit a value in the column. It will default to the editor factory provided by the toolkit for the type of the value.
label = Str()
The label of the column. It will default to a value derived from the name of the attribute that the column is bound to.

TableWidget

class dip.ui.TableWidget

Base class: EditorFactory

The TableWidget class implements a table widget editor factory for list attributes.

columns = List(Instance(TableColumn, str))
The list of columns. If a string is given then it is assumed to be the name of an attribute in the row model.
row_factory = Callable()
When called this will create the data for a new row in the table.
view_interface = ITableWidgetEditor
The specific interface that the view implements.
configure_delegate(editor, attribute_type, column, column_nr, toolkit)

Configure the delegate for a column of an editor created by the factory.

Parameters:
  • editor – is the editor.
  • attribute_type – is the list’s type.
  • column – is the TableColumn instance for the column.
  • column_nr – is the number of the column
  • toolkit – is the IToolkit implementation used to create the editor.
configure_widget_item(widget_item, attribute_type, column)

Configure a new widget item.

Parameters:
  • widget_item – is the widget item, usually a QTableWidgetItem instance.
  • attribute_type – is the list’s type.
create_editor(attribute_type, toolkit, parent)

Create the editor.

Parameters:
  • attribute_type – the type of the attribute the factory is being asked to handle. It should be a List.
  • toolkit – is the IToolkit implementation used to create the editor.
  • parent – is the optional parent widget.
Returns:

the editor.

create_row(attribute_type, columns)

Create a new row for the table.

Parameters:
  • attribute_type – is the list’s type.
  • columns – is the list of TableColumn instances for the columns.
Returns:

the new row.

table_columns(attribute_type, nr_columns)

Return the list of TableColumn instances describing the columns of the table.

Parameters:
  • attribute_type – is the type of the attribute the editor is bound to.
  • nr_columns – is the number of columns that the editor has. It is 0 if this is determined by the value returned by this method.
Returns:

the list of columns.

TextEdit

class dip.ui.TextEdit

Base class: EditorFactory

The TextEdit class implements a text editor editor factory for string attributes.

view_interface = ITextEditEditor
The specific interface that the view implements.
create_editor(attribute_type, toolkit, parent)

Create the editor.

Parameters:
  • attribute_type – the type of the attribute the factory is being asked to handle. It should be a Str.
  • toolkit – is the IToolkit implementation used to create the editor.
  • parent – is the optional parent widget.
Returns:

the editor.

ToolButton

class dip.ui.ToolButton

Base class: EditorFactory

The ToolButton class implements a tool button editor factory for trigger attributes.

extra_metadata_properties = ['icon']
Extra properties set from the attribute’s metadata.
view_interface = IToolButtonEditor
The specific interface that the view implements.
create_editor(attribute_type, toolkit, parent)

Create the editor.

Parameters:
  • attribute_type – the type of the attribute the factory is being asked to handle. It should be a Trigger.
  • toolkit – is the IToolkit implementation used to create the editor.
  • parent – is the optional parent widget.
Returns:

the editor.

UpButton

class dip.ui.UpButton

Base class: LinkedViewFactory

The UpButton class implements a factory for a button for moving an item up a collection editor.

id_suffix = '.up'
The suffix to add to the identifier to distinguish it from other linked editors.
create_view(controller, toolkit, parent)

Create the view.

Parameters:
  • controller – is the controller.
  • toolkit – is the IToolkit implementation used to create the view.
  • parent – is the optional parent widget.
Returns:

the view which will be an instance of QAbstractButton.

This is reimplemented to link the button view to the collection editor.

Parameters:
  • view – is the view.
  • editor – is the editor.

VBox

class dip.ui.VBox

Base class: BoxLayoutFactory

The VBox class arranges its contents vertically.

create_layout(items, toolkit)

Create a layout for a vertical sub-view.

Parameters:
  • items – is a sequence of QLayout, QWidget and Stretch instances.
  • toolkit – is the IToolkit implementation used to create the layout.
Returns:

the layout.

ViewFactory

class dip.ui.ViewFactory

Base class: QObjectFactory

The ViewFactory class is the base class for all factories that create views, sub-views and editors.

view_interface = Subclass(IView, default=IView)
The specific interface that the view implements.
__call__(model, toolkit, controller=None, parent=None)

Create a view for a model. This will always be a QWidget.

Parameters:
  • model – is the model which is either a Model instance or a Python mapping object.
  • toolkit – is the IToolkit implementation used to create the view.
  • controller – is the optional controller. If this is None then create_controller() will be called to create one.
  • parent – is the optional parent widget. It is typically only used for dialog based views.
Returns:

the QWidget that is the root of the view’s implementation.

bind(view, controller, toolkit)

Bind a view created by this factory.

Parameters:
  • view – is the view.
  • controller – is the controller.
  • toolkit – is the IToolkit implementation used to create the view.
create_controller()

Create an implementation of IController.

Returns:the controller.
create_view(controller, toolkit, parent)

Create the view.

This must be reimplemented by a sub-class.

Parameters:
  • controller – is the controller.
  • toolkit – is the IToolkit implementation used to create the view.
  • parent – is the optional parent widget.
Returns:

the QLayout or QWidget that is the root of the view’s implementation.

Wizard

class dip.ui.Wizard

Base class: CompositeViewFactory

The Wizard class implements a QWizard based wizard.

create_controller()

Create an implementation of IController.

Returns:the controller.
create_view(controller, toolkit, parent)

Create the view for a model.

Parameters:
  • controller – is the controller.
  • toolkit – is the IToolkit implementation used to create the dialog.
  • parent – is the optional parent widget.
Returns:

the QWizard instance that is the view’s implementation.

WizardController

class dip.ui.WizardController

Base class: Controller

The WizardController class is a controller for handling wizards.

validate_page(page_nr)

Validate the data in a page. This implementation considers the page to be valid if all its editors have valid values.

Parameter:page_nr – is the number of the page. This is the index of the page in the wizard and is not the same as the identifier allocated by Qt.
Returns:a string which will be empty if the page is valid, otherwise it will explain why the page is invalid.
validate_view()

Validate the data in the view. This implementation considers the view to be valid if all its editors have valid values.

Returns:a string which will be empty if the view is valid, otherwise it will explain why the view is invalid.

WizardPage

class dip.ui.WizardPage

Base class: SingleSubviewFactory

The WizardPage class implements a QWizardPage based wizard page.

create_view(controller, toolkit, parent)

Create the view for a model.

Parameters:
  • controller – is the controller.
  • toolkit – is the IToolkit implementation used to create the dialog.
  • parent – is the optional parent widget.
Returns:

the QLayout or QWidget that is the root of the view’s implementation.