pyface.i_widget module

The base interface for all pyface widgets.

class pyface.i_widget.IWidget(adaptee, default=<class 'traits.adaptation.adaptation_error.AdaptationError'>)[source]

Bases: Interface

The base interface for all pyface widgets.

Pyface widgets delegate to a toolkit specific control.

control = Any()

The toolkit specific control that represents the widget.

parent = Any()

The control’s optional parent control.

visible = Bool(True)

Whether or not the control is visible

enabled = Bool(True)

Whether or not the control is enabled

tooltip = Str()

A tooltip for the widget.

context_menu = Instance("pyface.action.menu_manager.MenuManager")

An optional context menu for the widget.

show(visible)[source]

Show or hide the widget.

Parameters

visible (bool) – Visible should be True if the widget should be shown.

enable(enabled)[source]

Enable or disable the widget.

Parameters

enabled (bool) – The enabled state to set the widget to.

focus()[source]

Set the keyboard focus to this widget.

has_focus()[source]

Does the widget currently have keyboard focus?

Returns

focus_state – Whether or not the widget has keyboard focus.

Return type

bool

create(parent=None)[source]

Creates the toolkit specific control.

This method should create the control and assign it to the control trait.

destroy()[source]

Destroy the control if it exists.

class pyface.i_widget.MWidget[source]

Bases: HasTraits

The mixin class that contains common code for toolkit specific implementations of the IWidget interface.

tooltip = Str()

A tooltip for the widget.

context_menu = Instance("pyface.action.menu_manager.MenuManager")

An optional context menu for the widget.

create(parent=None)[source]

Creates the toolkit specific control.

This method should create the control and assign it to the :py:attr:control trait.

destroy()[source]

Call clean-up code and destroy toolkit objects.

Subclasses should override to perform any additional clean-up, ensuring that they call super() after that clean-up.