spinetoolbox.widgets.multi_tab_window

Contains the MultiTabWindow and TabBarPlus classes.

Module Contents

Classes

MultiTabWindow

A main window that has a tab widget as its central widget.

TabBarPlus

Tab bar that has a plus button floating to the right of the tabs.

class spinetoolbox.widgets.multi_tab_window.MultiTabWindow(qsettings, settings_group)[source]

Bases: PySide6.QtWidgets.QMainWindow

A main window that has a tab widget as its central widget.

Parameters
  • qsettings (QSettings) – Toolbox settings

  • settings_group (str) – this window’s settings group in qsettings

property accepting_new_tabs[source]
property new_tab_title[source]

Title for new tabs.

_tab_slots[source]
_other_editor_windows[source]
abstract _make_other()[source]

Creates a new MultiTabWindow of this type.

Returns

new MultiTabWindow

Return type

MultiTabWindow

others()[source]

List of other MultiTabWindows of the same type.

Returns

other MultiTabWindows windows

Return type

list of MultiTabWindow

abstract _make_new_tab(*args, **kwargs)[source]

Creates a new tab.

Parameters
  • *args – positional arguments neede to make a new tab

  • **kwargs – keyword arguments needed to make a new tab

abstract show_plus_button_context_menu(global_pos)[source]

Opens a context menu for the toolbar.

Parameters

global_pos (QPoint) – menu position on screen

connect_signals()[source]

Connects window’s signals.

name()[source]

Generates name based on the current tab and total tab count.

Returns

a name

Return type

str

all_tabs()[source]

Iterates over tab contents widgets.

Yields

QWidget – tab contents widget

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

Creates a new tab and adds it at the end of the tab bar.

Parameters
  • *args – parameters forwarded to MutliTabWindow._make_new_tab()

  • **kwargs – parameters forwarded to MultiTabwindow._make_new_tab()

Returns

True if successful, False otherwise

Return type

bool

insert_new_tab(index, *args, **kwargs)[source]

Creates a new tab and inserts it at the given index.

Parameters
  • index (int) – insertion point index

  • *args – parameters forwarded to MutliTabWindow._make_new_tab()

  • **kwargs – parameters forwarded to MultiTabwindow._make_new_tab()

_add_connect_tab(tab, text)[source]

Appends a new tab and connects signals.

Parameters
  • tab (QWidget) – tab contents widget

  • text (str) – appended tab title

_insert_connect_tab(index, tab, text)[source]

Inserts a new tab and connects signals.

Parameters
  • index (int) – insertion point index

  • tab (QWidget) – tab contents widget

  • text (str) – inserted tab title

_remove_disconnect_tab(index)[source]

Disconnects and removes a tab.

Parameters

index (int) – tab index

_connect_tab(index)[source]

Connects signals from a tab contents widget.

Parameters

index (int) – tab index

_connect_tab_signals(tab)[source]

Connects signals from a tab contents widget.

Parameters

tab (QWidget) – tab contents widget

Returns

True if signals were connected successfully, False otherwise

Return type

bool

_disconnect_tab_signals(index)[source]

Disconnects signals from given tab.

Parameters

index (int) – tab index

Returns

True if signals were disconnected successfully, False otherwise

Return type

bool

_handle_tab_window_title_changed(tab, title)[source]

Updates tab’s title.

Parameters
  • tab (QWidget) – tab’s content widget

  • title (str) – new tab title; if emtpy, one will be generated

_take_tab(index)[source]

Removes a tab and returns its contents.

Parameters

index (int) – tab index

Returns

widget the tab was holding and tab’s title

Return type

tuple

move_tab(index, other=None)[source]

Moves a tab to another MultiTabWindow.

Parameters
  • index (int) – tab index

  • other (MultiTabWindow, optional) – target window; if None, creates a new window

detach(index, hot_spot, offset=0)[source]

Detaches the tab at given index into another MultiTabWindow window and starts dragging it.

Parameters
  • index (int) –

  • hot_spot (QPoint) –

  • offset (int) –

start_drag(hot_spot, offset=0)[source]

Starts dragging a detached tab.

Parameters
  • hot_spot (QPoint) – The anchor point of the drag in widget coordinates.

  • offset (int) – Horizontal offset of the tab in the bar.

_frame_height()[source]

Calculates the total ‘thickness’ of window frame in vertical direction.

Returns

frame height

Return type

int

timerEvent(event)[source]

Performs the drag, i.e., moves the window with the mouse cursor. As soon as the mouse hovers the tab bar of another MultiTabWindow, reattaches it.

mouseReleaseEvent(event)[source]

Stops the drag. This only happens when the detached tab is not reattached to another window.

reattach(index, tab, text)[source]

Reattaches a tab that has been dragged over this window’s tab bar.

Parameters
  • index (int) – Index in this widget’s tab bar where the detached tab has been dragged.

  • tab (QWidget) – The widget in the tab being dragged.

  • text (str) – The title of the tab.

handle_close_request_from_tab()[source]

Catches close event triggered by a QAction in tab’s QToolBar. Calls QTabWidgets close tabs method to ensure that the last closed tab closes the editor window.

_close_tab(index)[source]

Closes the tab at index.

Parameters

index (int) – tab index

set_current_tab(tab)[source]

Sets the tab that is shown on the window.

Parameters

tab (QWidget) – tab’s contents widget

make_context_menu(index)[source]

Creates a context menu for given tab.

Parameters

index (int) – tab index

Returns

context menu or None if tab was not found

Return type

QMenu

restore_ui()[source]

Restore UI state from previous session.

save_window_state()[source]

Save window state parameters (size, position, state) via QSettings.

closeEvent(event)[source]
class spinetoolbox.widgets.multi_tab_window.TabBarPlus(parent)[source]

Bases: PySide6.QtWidgets.QTabBar

Tab bar that has a plus button floating to the right of the tabs.

Parameters

parent (MultiSpineDBEditor) –

plus_clicked[source]
resizeEvent(event)[source]

Sets the dimension of the plus button. Also, makes the tab bar as wide as the parent.

tabLayoutChange()[source]
_move_plus_button()[source]

Places the plus button at the right of the last tab.

mousePressEvent(event)[source]

Registers the position of the press, in case we need to detach the tab.

mouseMoveEvent(event)[source]

Detaches a tab either if the user moves beyond the limits of the tab bar, or if it’s the only one.

_send_release_event(pos)[source]

Sends a mouse release event at given position in local coordinates. Called just before detaching a tab.

Parameters

pos (QPoint) –

mouseReleaseEvent(event)[source]
start_dragging(index)[source]

Stars dragging the given index. This happens when a detached tab is reattached to this bar.

Parameters

index (int) –

index_under_mouse()[source]

Returns the index under the mouse cursor, or None if the cursor isn’t over the tab bar. Used to check for drop targets.

Returns

int or NoneType

contextMenuEvent(event)[source]