spinetoolbox.project_item.specification_editor_window
Contains SpecificationEditorWindowBase and ChangeSpecPropertyCommand
Module Contents
Classes
Enum where members are also (and must be) ints |
|
Command to set specification properties. |
|
Base class for spec editors. |
|
QToolBar for line edits and a hamburger menu. |
Functions
|
Prompts to save changes. |
- class spinetoolbox.project_item.specification_editor_window.CommandId[source]
Bases:
enum.IntEnum
Enum where members are also (and must be) ints
Initialize self. See help(type(self)) for accurate signature.
- class spinetoolbox.project_item.specification_editor_window.ChangeSpecPropertyCommand(callback, new_value, old_value, cmd_name, command_id=CommandId.NONE)[source]
Bases:
PySide6.QtGui.QUndoCommand
Command to set specification properties.
- Parameters
callback (Callable) – Function to call to set the spec property.
new_value (Any) – new value
old_value (Any) – old value
cmd_name (str) – command name
command_id (IntEnum) – command id
- class spinetoolbox.project_item.specification_editor_window.SpecificationEditorWindowBase(toolbox, specification=None, item=None)[source]
Bases:
PySide6.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()[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(spec_name)[source]
Returns a ProjectItemSpecification from current form settings.
- Parameters
spec_name (str) – Name of the spec
- Returns
ProjectItemSpecification
- spec_toolbar()[source]
Returns spec editor window’s toolbar, which contains e.g. the hamburger menu.
- _save(exiting=None)[source]
Saves spec.
- Parameters
exiting (bool, optional) – Set as True if called when trying to exit the editor window
- Returns
True if operation was successful, False otherwise
- Return type
bool
- class spinetoolbox.project_item.specification_editor_window._SpecNameDescriptionToolbar(parent, spec, undo_stack)[source]
Bases:
PySide6.QtWidgets.QToolBar
QToolBar for line edits and a hamburger menu.
- Parameters
parent (QMainWindow) – QMainWindow instance
spec (ProjectItemSpecification) – specification that is being edited
undo_stack (QUndoStack) – an undo stack
- _update_name(name)[source]
Pushes a command to undo stack that updates the specification name.
- Parameters
name (str) – updated name
- spinetoolbox.project_item.specification_editor_window.prompt_to_save_changes(parent, settings, save_callback, exiting=None)[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’.
exiting (bool, optional) – Set as True if called when trying to exit the editor window
- Returns
False if the user chooses to cancel, in which case we don’t close the form.
- Return type
bool