spinetoolbox.widgets.custom_qwidgets

Custom QWidgets for Filtering and Zooming.

Module Contents

Classes

ElidedTextMixin

UndoRedoMixin

FilterWidget

Filter widget class.

CustomWidgetAction

A QWidgetAction with custom hovering.

ToolBarWidgetAction

An action with a tool bar.

ToolBarWidgetBase

A toolbar on the right, with enough space to print a text beneath.

ToolBarWidget

A toolbar on the right, with enough space to print a text beneath.

MenuItemToolBarWidget

A menu item with a toolbar on the right.

_MenuToolBar

A custom tool bar for MenuItemToolBarWidget.

TitleWidgetAction

A titled separator.

WrapLabel

A QLabel that always wraps text.

HyperTextLabel

A QLabel that supports hyperlinks.

QWizardProcessPage

A QWizards page with a log. Useful for pages that need to capture the output of a process.

LabelWithCopyButton

A read only QLabel with a QToolButton that copies the text to clipboard.

ElidedLabel

A QLabel with elided text.

HorizontalSpinBox

PropertyQSpinBox

A spinbox where undo and redo key strokes apply to the project.

SelectDatabaseItemsDialog

Dialog that lets selecting database items.

PurgeSettingsDialog

Dialog that lets selecting database items.

class spinetoolbox.widgets.custom_qwidgets.ElidedTextMixin(*args, **kwargs)[source]
setText(text)[source]
_update_text(text)[source]
_set_text_elided(width=None)[source]
_elided_offset()[source]
text()[source]
resizeEvent(event)[source]
class spinetoolbox.widgets.custom_qwidgets.UndoRedoMixin[source]
keyPressEvent(e)[source]

Overridden to catch and pass on the Undo and Redo commands when this line edit has the focus.

Parameters

e (QKeyEvent) – Event

class spinetoolbox.widgets.custom_qwidgets.FilterWidget(parent, make_filter_model, *args, **kwargs)[source]

Bases: PySide6.QtWidgets.QWidget

Filter widget class.

Init class.

Parameters
  • parent (QWidget, optional) – parent widget

  • make_filter_model (Callable) – callable that constructs the filter model

  • *args – arguments forwarded to make_filter_model

  • **kwargs – keyword arguments forwarded to make_filter_model

okPressed[source]
cancelPressed[source]
set_filter_list(items)[source]
connect_signals()[source]
save_state()[source]

Saves the state of the FilterCheckboxListModel.

reset_state()[source]

Sets the state of the FilterCheckboxListModel to saved state.

clear_filter()[source]

Selects all items in FilterCheckBoxListModel.

has_filter()[source]

Returns true if any item is filtered in FilterCheckboxListModel false otherwise.

_apply_filter()[source]

Apply current filter and save state.

_cancel_filter()[source]

Cancel current edit of filter and set the state to the stored state.

_filter_list()[source]

Filter list with current text.

_text_edited(new_text)[source]

Callback for edit text, starts/restarts timer. Start timer after text is edited, restart timer if text is edited before last time out.

class spinetoolbox.widgets.custom_qwidgets.CustomWidgetAction(parent=None)[source]

Bases: PySide6.QtWidgets.QWidgetAction

A QWidgetAction with custom hovering.

Class constructor.

Parameters

parent (QMenu) – the widget’s parent

_handle_hovered()[source]

Hides other menus that might be shown in the parent widget and repaints it. This is to emulate the behavior of QAction.

class spinetoolbox.widgets.custom_qwidgets.ToolBarWidgetAction(text, parent=None, compact=False)[source]

Bases: CustomWidgetAction

An action with a tool bar.

tool_bar
Type

QToolBar

Class constructor.

Parameters

parent (QMenu) – the widget’s parent

eventFilter(obj, ev)[source]
_handle_hovered()[source]

Hides other menus that might be shown in the parent widget and repaints it. This is to emulate the behavior of QAction.

class spinetoolbox.widgets.custom_qwidgets.ToolBarWidgetBase(text, parent=None, io_files=None)[source]

Bases: PySide6.QtWidgets.QWidget

A toolbar on the right, with enough space to print a text beneath.

tool_bar
Type

QToolBar

Class constructor.

Parameters
  • text (str) –

  • parent (QWidget) – the widget’s parent

class spinetoolbox.widgets.custom_qwidgets.ToolBarWidget(text, parent=None, io_files=None)[source]

Bases: ToolBarWidgetBase

A toolbar on the right, with enough space to print a text beneath.

tool_bar
Type

QToolBar

Class constructor.

Parameters
  • text (str) –

  • parent (QWidget) – the widget’s parent

class spinetoolbox.widgets.custom_qwidgets.MenuItemToolBarWidget(text, parent=None, compact=False)[source]

Bases: ToolBarWidgetBase

A menu item with a toolbar on the right.

Class constructor.

Parameters
  • text (str) –

  • parent (QWidget) – the widget’s parent

  • compact (bool) – if True, the widget uses the minimal space

paintEvent(event)[source]

Draws the menu item, then calls the super() method to draw the tool bar.

class spinetoolbox.widgets.custom_qwidgets._MenuToolBar(parent=None)[source]

Bases: PySide6.QtWidgets.QToolBar

A custom tool bar for MenuItemToolBarWidget.

enabled_changed[source]
_align_buttons()[source]

Align all buttons to bottom so frames look good.

add_frame(left, right, title)[source]

Add frame around given actions, with given title.

Parameters
  • left (QAction) –

  • right (QAction) –

  • title (str) –

is_enabled()[source]
addActions(actions)[source]

Overriden method to customize tool buttons.

addAction(*args, **kwargs)[source]

Overriden method to customize the tool button.

sizeHint()[source]

Make room for frames if needed.

paintEvent(ev)[source]

Paint the frames.

_setup_action_button(action)[source]
Customizes the QToolButton associated with given action:
  1. Makes sure that the text honors the action’s mnemonics.

  2. Installs this as event filter on the button (see self.eventFilter()).

Must be called everytime an action is added to the tool bar.

Parameters

action (QAction) – Action to set up

actionEvent(ev)[source]

Updates self._enabled: True if at least one non-separator action is enabled, False otherwise. Emits self.enabled_changed accordingly.

eventFilter(obj, ev)[source]

Installed on each action’s QToolButton. Ignores Up and Down key press events, so they are handled by the toolbar for custom navigation.

keyPressEvent(ev)[source]

Navigates over the tool bar buttons.

hideEvent(ev)[source]
class spinetoolbox.widgets.custom_qwidgets.TitleWidgetAction(title, parent=None)[source]

Bases: CustomWidgetAction

A titled separator.

Class constructor.

Parameters

parent (QMenu) – the widget’s parent

H_MARGIN = 5[source]
V_MARGIN = 2[source]
static _add_line(widget, layout)[source]
isSeparator()[source]
class spinetoolbox.widgets.custom_qwidgets.WrapLabel(text='', parent=None)[source]

Bases: PySide6.QtWidgets.QLabel

A QLabel that always wraps text.

class spinetoolbox.widgets.custom_qwidgets.HyperTextLabel(text='', parent=None)[source]

Bases: WrapLabel

A QLabel that supports hyperlinks.

class spinetoolbox.widgets.custom_qwidgets.QWizardProcessPage(parent)[source]

Bases: PySide6.QtWidgets.QWizardPage

A QWizards page with a log. Useful for pages that need to capture the output of a process.

class _ExecutionManager[source]

A descriptor that stores a QProcessExecutionManager. When execution_finished is emitted, it shows the button to copy the process log.

public_name[source]
private_name[source]
__set_name__(owner, name)[source]
__get__(obj, objtype=None)[source]
__set__(obj, value)[source]
msg[source]
msg_warning[source]
msg_error[source]
msg_success[source]
msg_proc[source]
msg_proc_error[source]
_exec_mngr[source]
_connect_signals()[source]
_handle_copy_clicked(_=False)[source]
_add_msg(msg)[source]
_add_msg_warning(msg)[source]
_add_msg_error(msg)[source]
_add_msg_success(msg)[source]
isComplete()[source]
cleanupPage()[source]
class spinetoolbox.widgets.custom_qwidgets.LabelWithCopyButton(text='', parent=None)[source]

Bases: PySide6.QtWidgets.QWidget

A read only QLabel with a QToolButton that copies the text to clipboard.

class spinetoolbox.widgets.custom_qwidgets.ElidedLabel(*args, **kwargs)[source]

Bases: ElidedTextMixin, PySide6.QtWidgets.QLabel

A QLabel with elided text.

class spinetoolbox.widgets.custom_qwidgets.HorizontalSpinBox(*args, **kwargs)[source]

Bases: PySide6.QtWidgets.QToolBar

valueChanged[source]
value()[source]
setMinimum(minimum)[source]
setMaximum(maximum)[source]
setValue(value, strict=False)[source]
_dec_value()[source]
_inc_value()[source]
_focus_line_edit()[source]
class spinetoolbox.widgets.custom_qwidgets.PropertyQSpinBox[source]

Bases: UndoRedoMixin, PySide6.QtWidgets.QSpinBox

A spinbox where undo and redo key strokes apply to the project.

class spinetoolbox.widgets.custom_qwidgets.SelectDatabaseItemsDialog(checked_states, ok_button_text=None, parent=None)[source]

Bases: PySide6.QtWidgets.QDialog

Dialog that lets selecting database items.

Parameters
  • checked_states (dict, optional) – checked states for each item

  • ok_button_text (str, optional) – alternative label for the OK button

  • parent (QWidget, optional) – parent widget

_warn_checked_non_data_items = True[source]
_ok_button_can_be_disabled = True[source]
show()[source]

Sets the OK button enabled before showing the dialog

get_checked_states()[source]

Returns current item checked states.

Returns

mapping from database item name to checked flag

Return type

dict

_handle_check_box_state_changed(_checked)[source]
class spinetoolbox.widgets.custom_qwidgets.PurgeSettingsDialog(checked_states, ok_button_text=None, parent=None)[source]

Bases: SelectDatabaseItemsDialog

Dialog that lets selecting database items.

Parameters
  • checked_states (dict, optional) – checked states for each item

  • ok_button_text (str, optional) – alternative label for the OK button

  • parent (QWidget, optional) – parent widget

_ok_button_can_be_disabled = False[source]