spinetoolbox.widgets.multi_tab_window
Contains the MultiTabWindow and TabBarPlus classes.
Module Contents
Classes
A main window that has a tab widget as its central widget. |
|
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
- abstract _make_other()[source]
Creates a new MultiTabWindow of this type.
- Returns
new MultiTabWindow
- Return type
- 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
Opens a context menu for the toolbar.
- Parameters
global_pos (QPoint) – menu position on screen
- name()[source]
Generates name based on the current tab and total tab count.
- Returns
a name
- Return type
str
- 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.
- set_current_tab(tab)[source]
Sets the tab that is shown on the window.
- Parameters
tab (QWidget) – tab’s contents widget
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
- 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) –
- resizeEvent(event)[source]
Sets the dimension of the plus button. Also, makes the tab bar as wide as the parent.
- 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) –
- start_dragging(index)[source]
Stars dragging the given index. This happens when a detached tab is reattached to this bar.
- Parameters
index (int) –