spinetoolbox.widgets.custom_menus

Classes for custom context menus and pop-up menus.

author
  1. Savolainen (VTT)

date

9.1.2018

Module Contents

Classes

CustomContextMenu

Context menu master class for several context menus.

ProjectItemContextMenu

Context menu for project items in the Project tree widget and in the Design View.

LinkContextMenu

Context menu class for connection links.

OpenProjectDialogComboBoxContextMenu

Context menu master class for several context menus.

CustomPopupMenu

Popup menu master class for several popup menus.

ItemSpecificationMenu

Context menu class for item specifications.

RecentProjectsPopupMenu

Recent projects menu embedded to ‘File-Open recent’ QAction.

FilterMenuBase

Filter menu.

SimpleFilterMenu

Filter menu.

class spinetoolbox.widgets.custom_menus.CustomContextMenu(parent, position)[source]

Bases: PySide2.QtWidgets.QMenu

Context menu master class for several context menus.

Parameters
  • parent (QWidget) – Parent for menu widget (ToolboxUI)

  • position (QPoint) – Position on screen

add_action(self, text, icon=QIcon(), enabled=True)[source]

Adds an action to the context menu.

Parameters
  • text (str) – Text description of the action

  • icon (QIcon) – Icon for menu item

  • enabled (bool) – Is action enabled?

set_action(self, option)[source]

Sets the action which was clicked.

Parameters

option (str) – string with the text description of the action

get_action(self)[source]

Returns the clicked action, a string with a description.

class spinetoolbox.widgets.custom_menus.ProjectItemContextMenu(parent, position)[source]

Bases: CustomContextMenu

Context menu for project items in the Project tree widget and in the Design View.

Parameters
  • parent (QWidget) – Parent for menu widget (ToolboxUI)

  • position (QPoint) – Position on screen

class spinetoolbox.widgets.custom_menus.LinkContextMenu(parent, position, link)[source]

Bases: CustomContextMenu

Context menu class for connection links.

Parameters
  • parent (QWidget) – Parent for menu widget (ToolboxUI)

  • position (QPoint) – Position on screen

  • link (Link(QGraphicsPathItem)) – Link that requested the menu

class spinetoolbox.widgets.custom_menus.OpenProjectDialogComboBoxContextMenu(parent, position)[source]

Bases: CustomContextMenu

Context menu master class for several context menus.

Parameters
  • parent (QWidget) – Parent for menu widget

  • position (QPoint) – Position on screen

class spinetoolbox.widgets.custom_menus.CustomPopupMenu(parent)[source]

Bases: PySide2.QtWidgets.QMenu

Popup menu master class for several popup menus.

Parameters

parent (QWidget) – Parent widget of this pop-up menu

add_action(self, text, slot, enabled=True, tooltip=None)[source]

Adds an action to the popup menu.

Parameters
  • text (str) – Text description of the action

  • slot (method) – Method to connect to action’s triggered signal

  • enabled (bool) – Is action enabled?

  • tooltip (str) – Tool tip for the action

class spinetoolbox.widgets.custom_menus.ItemSpecificationMenu(toolbox, index, item=None)[source]

Bases: CustomPopupMenu

Context menu class for item specifications.

Parameters
  • toolbox (ToolboxUI) – Toolbox that requests this menu, used as parent.

  • index (QModelIndex) – the index

  • item (ProjectItem, optional) – passed to show_specification_form

class spinetoolbox.widgets.custom_menus.RecentProjectsPopupMenu(parent)[source]

Bases: CustomPopupMenu

Recent projects menu embedded to ‘File-Open recent’ QAction.

Parameters

parent (QWidget) – Parent widget of this menu (ToolboxUI)

add_recent_projects(self)[source]

Reads the previous project names and paths from QSettings. Adds them to the QMenu as QActions.

call_open_project(self, checked, p)[source]

Slot for catching the user selected action from the recent projects menu.

Parameters
  • checked (bool) – Argument sent by triggered signal

  • p (str) – Full path to a project file

class spinetoolbox.widgets.custom_menus.FilterMenuBase(parent)[source]

Bases: PySide2.QtWidgets.QMenu

Filter menu.

Parameters

parent (QWidget) – a parent widget

connect_signals(self)[source]
set_filter_list(self, data)[source]
add_items_to_filter_list(self, items)[source]
remove_items_from_filter_list(self, items)[source]
_clear_filter(self)[source]
_check_filter(self)[source]
_change_filter(self)[source]
abstract emit_filter_changed(self, valid_values)[source]
wipe_out(self)[source]
class spinetoolbox.widgets.custom_menus.SimpleFilterMenu(parent, show_empty=True)[source]

Bases: FilterMenuBase

Filter menu.

Parameters

parent (SpineDBEditor) –

filterChanged[source]
emit_filter_changed(self, valid_values)[source]