From 26bb9a0623a37a3bf235648cd48252b1b2d4d669 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Wed, 15 Jun 2016 14:20:26 +0200 Subject: o Reusing the same instance of the dock widget. Controlling visibility instead of using show(). --- InitGui.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/InitGui.py b/InitGui.py index 316d1ea..978950f 100644 --- a/InitGui.py +++ b/InitGui.py @@ -1,15 +1,20 @@ class ShowPanelCommandClass(): + + def __init__(self): + self.widgetAdded = False + def GetResources(self): return {'MenuText': "Show Panel"} def Activated(self): from PySide import QtCore import BoxerGui - print('ShowPanelCommandClass.Activated') - window = FreeCADGui.getMainWindow() - window.addDockWidget(QtCore.Qt.RightDockWidgetArea, BoxerGui.gui.dockWidget) - BoxerGui.gui.dockWidget.show() + if not self.widgetAdded: + window = FreeCADGui.getMainWindow() + window.addDockWidget(QtCore.Qt.RightDockWidgetArea, BoxerGui.gui.dockWidget) + self.widgetAdded = True + BoxerGui.gui.dockWidget.setVisible(True) return @@ -24,7 +29,7 @@ class BoxerWorkbench(Workbench): def Initialize(self): self.list = ["BoxerShowPanel"] - self.appendToolbar("Boxer Commands", self.list) + self.appendToolbar("Boxer", self.list) import BoxerGui # Loads the Boxer modules def Activated(self): -- cgit v1.2.3