uicommand: interfacing commands with UI elements¶
Whereas Command object encapsulate something that happens to the model, UICommand objects are associated to an UI element and are triggered by it (it’s actually a subclass of QAction). They will typically create a new Command and run it in their do() method, each time it’s invoked.
Integration of commands with UI elements
-
class
pyqtcmd.uicommand.
NeedsSelectionUICommandMixin
(parent=None, *, container, **kwargs)[source]¶ A mixin for UICommand. The constructor takes a container keyword argument. This must be an object which implements a selectionChanged signal (of any signature) and a selection() method, which should return the selection as an object with a __len__.
-
class
pyqtcmd.uicommand.
RedoUICommandMixin
(*args, text=None, **kwargs)[source]¶ Redo UICommand. This is a mixin so you can inherit from your concrete UICommand subclass.
-
class
pyqtcmd.uicommand.
UICommand
(parent=None, *, text=None, icon=None, shortcut=None, tip=None)[source]¶ An UICommand is the intermediate between UI elements and the underlying Commands. A Command encapsulates a single behavior; an UICommand has a longer life time since it’s associated to a UI element. Its role is to instantiate and run the right Command when the user interacts with the element. It also has an enabled/disabled state that you can manage by overriding the should_be_enabled() method.
-
add_signal_check
(signal)[source]¶ Call this, passing it a signal that could change the UIAction state (enabled/disabled, etc) when it’s fired. The signal’s signature does not matter.
-
do
()[source]¶ Subclasses should override this to do whatever is necessary (for instance show a dialog for choosing a file name, etc) and then instantiate the right Command class and run() it.
Associates this command to a push button.
-