spinetoolbox.project_item.specification_editor_window
¶
Contains SpecificationEditorWindowBase and ChangeSpecPropertyCommand
- author
Marin (KTH), P. Savolainen (VTT)
- date
12.4.2018
Module Contents¶
Classes¶
Command to set specification properties. |
|
Base class for spec editors. |
|
A QToolBar to let users set name and description for an Spec. |
Functions¶
|
Prompts to save changes. |
|
Restores UI state from previous session. |
|
Saves UI state for next session. |
- class spinetoolbox.project_item.specification_editor_window.ChangeSpecPropertyCommand(callback, new_value, old_value, cmd_name)[source]¶
Bases:
PySide2.QtWidgets.QUndoCommand
Command to set specification properties.
- Parameters
callback (function) – Function to call to set the spec property.
new_value (any) – new value
old_value (any) – old value
cmd_name (str) – command name
- class spinetoolbox.project_item.specification_editor_window.SpecificationEditorWindowBase(toolbox, specification=None, item=None)[source]¶
Bases:
PySide2.QtWidgets.QMainWindow
Base class for spec editors.
- Parameters
toolbox (ToolboxUI) – QMainWindow instance
specification (ProjectItemSpecification, optional) – If given, the form is pre-filled with this specification
item (ProjectItem, optional) – Sets the spec for this item if accepted
- _restore_dock_widgets(self)[source]¶
Restores dockWidgets to some default state. Called in the constructor, before restoring the ui from settings. Reimplement in subclasses if needed.
- abstract _make_new_specification(self, spec_name)[source]¶
Returns a ProjectItemSpecification from current form settings.
- Parameters
spec_name (str) – Name of the spec
- Returns
ProjectItemSpecification
- class spinetoolbox.project_item.specification_editor_window._SpecNameDescriptionToolbar(parent, spec, undo_stack)[source]¶
Bases:
PySide2.QtWidgets.QToolBar
A QToolBar to let users set name and description for an Spec.
- Parameters
parent (QMainWindow) – QMainWindow instance
spec (ProjectItemSpecification) – specification that is being edited
undo_stack (QUndoStack) – an undo stack
- spinetoolbox.project_item.specification_editor_window.prompt_to_save_changes(parent, settings, save_callback)[source]¶
Prompts to save changes.
- Parameters
parent (QWidget) – Spec editor widget
settings (QSettings) – Toolbox settings
save_callback (Callable) – A function to call if the user chooses Save. It must return True or False depending on the outcome of the ‘saving’.
- Returns
False if the user chooses to cancel, in which case we don’t close the form.
- Return type
bool