Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

Commit 187592d

Browse files
authored
Merge pull request #129 from PyMoDAQ/feature/reference_toolbar_menu
create two methods to reference in the action manager existing toolba…
2 parents 79da109 + 1095e0b commit 187592d

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/pymodaq_gui/managers/action_manager.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,20 @@ def add_menu(self, short_name: str, title: str, menu: QtWidgets.QMenu = None,
433433

434434
return new_menu
435435

436+
def reference_toolbar(self, short_name: str, toolbar: QtWidgets.QToolBar):
437+
""" Add an existing toolbar to the list of managed toolbars"""
438+
if short_name not in self._toolbars:
439+
self._toolbars[short_name] = toolbar
440+
else:
441+
raise KeyError(f'Toolbar {short_name} is already existing')
442+
443+
def reference_menu(self, short_name: str, menu: QtWidgets.QMenu):
444+
""" Add an existing toolbar to the list of managed toolbars"""
445+
if short_name not in self._menus:
446+
self._menus[short_name] = menu
447+
else:
448+
raise KeyError(f'Menu {short_name} is already existing')
449+
436450
def add_toolbar(self, short_name: str, title: str = '', parent: QtWidgets.QWidget = None) -> QtWidgets.QToolBar:
437451
"""Create and add a toolbar
438452

src/pymodaq_gui/utils/custom_app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def __init__(self, parent: Union[DockArea, QtWidgets.QMainWindow, QtWidgets.QWid
7070
self.mainwindow.addToolBar(self._toolbar)
7171
self._menubar = self.mainwindow.menuBar()
7272
self.statusbar = self.mainwindow.statusBar()
73+
self.reference_toolbar('main', self._toolbar)
7374

7475

7576
def setup_ui(self):

0 commit comments

Comments
 (0)