spinetoolbox.project_item.specification_editor_window

Contains SpecificationEditorWindowBase and ChangeSpecPropertyCommand

author
  1. Marin (KTH), P. Savolainen (VTT)

date

12.4.2018

Module Contents

Classes

ChangeSpecPropertyCommand

Command to set specification properties.

SpecificationEditorWindowBase

Base class for spec editors.

_SpecNameDescriptionToolbar

A QToolBar to let users set name and description for an Spec.

Functions

prompt_to_save_changes(parent, settings, save_callback)

Prompts to save changes.

restore_ui(window, app_settings, settings_group)

Restores UI state from previous session.

save_ui(window, app_settings, settings_group)

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

redo(self)[source]
undo(self)[source]
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

property settings_group(self)[source]

Returns the settings group for this spec type.

Returns

str

abstract _make_ui(self)[source]

Returns the ui object from Qt designer.

Returns

object

_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

_show_error(self, message)[source]
_show_status_bar_msg(self, msg)[source]
_populate_main_menu(self)[source]
_update_window_modified(self, clean)[source]
_save(self)[source]

Saves spec.

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

_make_main_menu(self)[source]
_set_name(self)[source]
_set_description(self)[source]
do_set_name(self, name)[source]
do_set_description(self, description)[source]
name(self)[source]
description(self)[source]
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

spinetoolbox.project_item.specification_editor_window.restore_ui(window, app_settings, settings_group)[source]

Restores UI state from previous session.

Parameters
  • window (QMainWindow) –

  • app_settings (QSettings) –

  • settings_group (str) –

spinetoolbox.project_item.specification_editor_window.save_ui(window, app_settings, settings_group)[source]

Saves UI state for next session.

Parameters
  • window (QMainWindow) –

  • app_settings (QSettings) –

  • settings_group (str) –