spinetoolbox.project_item.specification_editor_window

Contains SpecificationEditorWindowBase and ChangeSpecPropertyCommand

Module Contents

Classes

UniqueCommandId

CommandId

Enum where members are also (and must be) ints

ChangeSpecPropertyCommand

Command to set specification properties.

SpecificationEditorWindowBase

Base class for spec editors.

_SpecNameDescriptionToolbar

QToolBar for line edits and a hamburger menu.

Functions

prompt_to_save_changes(parent, settings, save_callback)

Prompts to save changes.

class spinetoolbox.project_item.specification_editor_window.UniqueCommandId[source]
_NEXT_ID = 1[source]
classmethod unique_id()[source]

Returns a new unique command id.

Returns

unique id

Return type

int

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.

NONE[source]
NAME_UPDATE[source]
DESCRIPTION_UPDATE[source]
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

redo()[source]
undo()[source]
id()[source]
mergeWith(other)[source]
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

abstract property settings_group[source]

Returns the settings group for this spec type.

Returns

str

property _duplicate_kwargs[source]
abstract _make_ui()[source]

Returns the ui object from Qt designer.

Returns

object

_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.

show_error(message)[source]
_show_status_bar_msg(msg)[source]
_populate_main_menu()[source]
_update_window_modified(clean)[source]
_set_window_title(title)[source]

Sets window title.

Parameters

title (str) – new window title

_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

prompt_exit_without_saving()[source]

Prompts whether the user wants to exit without saving or cancel the exit.

Returns

False if the user chooses to cancel, in which case we don’t close the form.

Return type

bool

_duplicate()[source]
tear_down()[source]
closeEvent(event)[source]
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

name_changed[source]
_make_main_menu()[source]
_update_name(name)[source]

Pushes a command to undo stack that updates the specification name.

Parameters

name (str) – updated name

_finish_name_editing()[source]

Seals the last undo command.

_update_description(description)[source]

Pushes a command to undo stack that updates the specification description.

Parameters

description (str) – updated description

_finish_description_editing()[source]

Seals the last undo command.

do_set_name(name)[source]
do_set_description(description)[source]
name()[source]
description()[source]
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