fsleyes.actions.base¶
This module provides the Action and ToggleAction classes.
See the actions package documentation for more details.
-
exception
fsleyes.actions.base.ActionDisabledError¶ Bases:
ExceptionException raised when an attempt is made to call a disabled
Action.-
__module__= 'fsleyes.actions.base'¶
-
__weakref__¶ list of weak references to the object (if defined)
-
-
class
fsleyes.actions.base.BoundWidget(parent, evType, widget)¶ Bases:
objectContainer class used by
Actioninstances to store references to widgets that are currently bound to them.-
__init__(parent, evType, widget)¶ Initialize self. See help(type(self)) for accurate signature.
-
isAlive()¶ Returns
Trueif the widget contained by thisBoundWidgetis still alive,Falseotherwise.
-
__dict__= mappingproxy({'__module__': 'fsleyes.actions.base', '__doc__': 'Container class used by :class:`Action` instances to store references\n to widgets that are currently bound to them.\n ', '__init__': <function BoundWidget.__init__>, 'isAlive': <function BoundWidget.isAlive>, '__dict__': <attribute '__dict__' of 'BoundWidget' objects>, '__weakref__': <attribute '__weakref__' of 'BoundWidget' objects>})¶
-
__module__= 'fsleyes.actions.base'¶
-
__weakref__¶ list of weak references to the object (if defined)
-
-
class
fsleyes.actions.base.Action(func, instance=None, name=None)¶ Bases:
__main__.MockClassRepresents an action of some sort.
-
enabled= <MagicMock name='mock.Boolean()' id='139845844115072'>¶ Controls whether the action is currently enabled or disabled. When this property is
Falsecalls to the action will result in aActionDisabledError.
-
__init__(func, instance=None, name=None)¶ Create an
Action.Parameters: - func – The action function.
- instance – Object associated with the function, if this
Actionis encapsulating an instance method. - name – Action name. Defaults to
func.__name__.
Note
If an
Actionencapsulates a method of anActionProviderinstance, it is assumed that thenameis the name of the method on the instance.
-
__str__()¶ Returns a string representation of this
Action.
-
__repr__()¶ Returns a string representation of this
Action.
-
name()¶ Returns the name of this
Action.
-
__call__(*args, **kwargs)¶ Calls this action. An
ActionDisabledErrorwill be raised ifenabledisFalse.
-
destroy()¶ Must be called when this
Actionis no longer needed.
-
bindToWidget(parent, evType, widget, wrapper=None)¶ Binds this action to the given
wxwidget.Parameters: - parent – The
wxobject on which the event should be bound. - evType – The
wxevent type. - widget – The
wxwidget. - wrapper – Optional custom wrapper function used to execute the action.
- parent – The
-
unbindWidget(widget)¶ Unbinds the given widget from this
Action.
-
unbindAllWidgets()¶ Unbinds all widgets which have been bound via
bindToWidget().
-
getBoundWidgets()¶ Returns a list of
BoundWidgetinstances, containing all widgets which have been bound to thisAction.
-
_Action__enabledChanged(*args)¶ Internal method which is called when the
enabledproperty changes. Enables/disables any bound widgets.
-
_Action__unbindWidget(index)¶ Unbinds the widget at the specified index into the
__boundWidgetslist. Does not remove it from the list.
-
__module__= 'fsleyes.actions.base'¶
-
-
class
fsleyes.actions.base.ToggleAction(*args, **kwargs)¶ Bases:
fsleyes.actions.base.ActionA
ToggleActionanActionwhich is intended to encapsulate actions that toggle some sort of state. For example, aToggleActioncould be used to encapsulate an action which opens and/or closes a dialog window.-
toggled= <MagicMock name='mock.Boolean()' id='139845844115072'>¶ Boolean which tracks the current state of the
ToggleAction.
-
__init__(*args, **kwargs)¶ Create a
ToggleAction. All arguments are passed toAction.__init__().
-
_ToggleAction__setState(widget)¶ Sets the toggled state of the given widget to the current value of
toggled.
-
_ToggleAction__toggledChanged(*a)¶ Internal method called when
toggledchanges. Updates the state of any bound widgets.
-
__module__= 'fsleyes.actions.base'¶
-