MVC Controller Utils (rafcon.gui.controllers.utils)

EditorController (in editor)

class rafcon.gui.controllers.utils.editor.EditorController(model, view, observed_method='script_text')

Bases: ExtendedController

Controller handling the text editor for States.

:param :param rafcon.gui.views.source_editor.EditorView view: The GTK view showing the editor.

after_notification_of_script_text_was_changed(model, prop_name, info)
apply_clicked(button)

Triggered when the Apply-Shortcut in the editor is triggered.

cancel_clicked(button)

Triggered when the Cancel-Shortcut in the editor is triggered

Resets the code in the editor to the last-saved code.

code_changed(source)

Apply checks and adjustments of the TextBuffer and TextView after every change in buffer.

The method re-apply the tag (style) for the buffer. It avoids changes while editable-property set to False which are caused by a bug in the GtkSourceView2. GtkSourceView2 is the default used TextView widget here. The text buffer is reset after every change to last stored source-text by a respective work around which suspends any generation of undo items and avoids a recursive call of the method set_enabled by observing its while_in_set_enabled flag.

Parameters:

source (TextBuffer) –

Returns:

register_actions(shortcut_manager)

Register callback methods for triggered actions

Parameters:

shortcut_manager (rafcon.gui.shortcut_manager.ShortcutManager) – Shortcut Manager Object holding mappings between shortcuts and actions.

register_view(view)

Called when the View was registered

Can be used e.g. to connect signals. Here, this implements a convenient feature that observes if thread problems are possible by destroying a controller before being fully initialized.

set_script_text(text)
property source_text

ExtendedController (in extended_controller)

class rafcon.gui.controllers.utils.extended_controller.ExtendedController(model, view)

Bases: Controller

add_controller(key, controller)

Add child controller

The passed controller is registered as child of self. The register_actions method of the child controller is called, allowing the child controller to register shortcut callbacks.

Parameters:
  • key – Name of the controller (unique within self), to later access it again

  • controller (ExtendedController) – Controller to be added as child

connect_signal(widget, signal, callback)
destroy()

Recursively destroy all Controllers

The method remove all controllers, which calls the destroy method of the child controllers. Then, all registered models are relieved and and the widget hand by the initial view argument is destroyed.

disconnect_all_signals()
get_child_controllers()

Returns a list with all registered child controllers

Returns:

List of child controllers

Return type:

list

get_controller(key)

Return the child controller registered with the name key

Parameters:

key – The name of the controller

Returns:

The controller

Return type:

ExtendedController

get_controller_by_path(ctrl_path, with_print=False)
get_root_window()
observe_model(model)

Make this model observable within the controller

The method also keeps track of all observed models, in order to be able to relieve them later on.

Parameters:

model (gtkmvc3.Model) – The model to be observed

property parent

Return the parent controller for which this controller is registered as a child.

Returns:

The parent controller

Return type:

ExtendedController

register_actions(shortcut_manager)

Register callback methods for triggered actions in all child controllers.

Parameters:

shortcut_manager (rafcon.gui.shortcut_manager.ShortcutManager) – Shortcut Manager Object holding mappings between shortcuts and actions.

register_view(view)

Called when the View was registered

Can be used e.g. to connect signals. Here, this implements a convenient feature that observes if thread problems are possible by destroying a controller before being fully initialized.

relieve_all_models()

Relieve all registered models

The method uses the set of registered models to relieve them.

relieve_model(model)

Do no longer observe the model

The model is also removed from the internal set of tracked models.

Parameters:

model (gtkmvc3.Model) – The model to be relieved

remove_controller(controller)

Remove child controller and destroy it

Removes all references to the child controller and calls destroy() on the controller.

Parameters:

controller (str | ExtendedController) – Either the child controller object itself or its registered name

Returns:

Whether the controller was existing

Return type:

bool

unregister_actions(shortcut_manager)

SingleWidgetWindowController (in single_widget_window)

class rafcon.gui.controllers.utils.single_widget_window.SingleWidgetWindowController(model, view, ctrl_class, *args, **kwargs)

Bases: ExtendedController

Controller handling the view of properties/attributes of …

register_view(view)

Called when the View was registered

Can be used e.g. to connect signals. Here, the destroy signal is connected to close the application