spinetoolbox.widgets.multi_tab_window

Contains the MultiTabWindow and TabBarPlus classes.

author
  1. Marin (KTH)

date

12.12.2020

Module Contents

Classes

MultiTabWindow

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, parent=None)[source]

Bases: PySide2.QtWidgets.QMainWindow

_tab_slots[source]
abstract _make_other(self)[source]
abstract others(self)[source]
abstract _make_new_tab(self, *args, **kwargs)[source]
abstract show_plus_button_context_menu(self, global_pos)[source]
property new_tab_title(self)[source]
connect_signals(self)[source]
name(self)[source]
all_tabs(self)[source]
add_new_tab(self, *args, **kwargs)[source]

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

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

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

Parameters

index (int) –

_add_connect_tab(self, tab, text)[source]
_insert_connect_tab(self, index, tab, text)[source]
_remove_disconnect_tab(self, index)[source]
_connect_tab(self, index)[source]
_connect_tab_signals(self, tab)[source]
_disconnect_tab_signals(self, index)[source]
_handle_tab_window_title_changed(self, tab, title)[source]
_take_tab(self, index)[source]
move_tab(self, index, other=None)[source]
detach(self, 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(self, 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, optional) – Horizontal offset of the tab in the bar.

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

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

reattach(self, index, db_editor, 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.

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

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

_close_tab(self, index)[source]

Closes the tab at index.

Parameters

index (int) –

set_current_tab(self, tab)[source]
make_context_menu(self, index)[source]
restore_ui(self)[source]

Restore UI state from previous session.

save_window_state(self)[source]

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

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

Bases: PySide2.QtWidgets.QTabBar

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

Parameters

parent (MultiSpineDBEditor) –

plus_clicked[source]
resizeEvent(self, event)[source]

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

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

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

mousePressEvent(self, event)[source]

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

mouseMoveEvent(self, 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(self, pos)[source]

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

Parameters

pos (QPoint) –

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

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

Parameters

index (int) –

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