Skip to content

Commit 5d344a4

Browse files
committed
create dedicated toolbar for plugin
1 parent f7fc870 commit 5d344a4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

arho_feature_template/plugin.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ def __init__(self) -> None:
4343
self.actions: list[QAction] = []
4444
self.menu = Plugin.name
4545

46+
self.toolbar = iface.addToolBar("ARHO Toolbar")
47+
4648
def add_action(
4749
self,
4850
icon_path: str,
@@ -114,7 +116,7 @@ def add_action(
114116
action.setCheckable(True)
115117

116118
if add_to_toolbar:
117-
iface.addToolBarIcon(action)
119+
self.toolbar.addAction(action)
118120

119121
if add_to_menu:
120122
iface.addPluginToMenu(self.menu, action)
@@ -214,6 +216,7 @@ def unload(self) -> None:
214216
for action in self.actions:
215217
iface.removePluginMenu(Plugin.name, action)
216218
iface.removeToolBarIcon(action)
219+
iface.mainWindow().removeToolBar(self.toolbar)
217220
teardown_logger(Plugin.name)
218221

219222
self.templater.template_dock.close()

0 commit comments

Comments
 (0)