diff --git a/CHANGELOG.md b/CHANGELOG.md index 85e3839e..051529f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ CHANGELOG for FlatCAM beta ================================================= +16.11.2020 + +- modified the behavior of the Tool Tab in the Notebook widget. Now the app start with the Tool Tab off. If an App Tool is launched then the Tool Tab is added and populated. If the same App Tool is launched again and the focus is in its Tool Tab then the Tool Tab is removed but if the focus is elsewhere then the focus is set again on the Tool Tab. + 15.11.2020 - working on adding new feature to Punch Gerber Tool - manual selection of pads to be punched diff --git a/appGUI/MainGUI.py b/appGUI/MainGUI.py index 3825ceef..1e35ef33 100644 --- a/appGUI/MainGUI.py +++ b/appGUI/MainGUI.py @@ -1373,7 +1373,8 @@ class MainGUI(QtWidgets.QMainWindow): self.tool_tab.setObjectName("tool_tab") self.tool_tab_layout = QtWidgets.QVBoxLayout(self.tool_tab) self.tool_tab_layout.setContentsMargins(2, 2, 2, 2) - self.notebook.addTab(self.tool_tab, _("Tool")) + # self.notebook.addTab(self.tool_tab, _("Tool")) + self.tool_scroll_area = VerticalScrollArea() # self.tool_scroll_area.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents) self.tool_tab_layout.addWidget(self.tool_scroll_area) diff --git a/appTools/ToolAlignObjects.py b/appTools/ToolAlignObjects.py index 6a509c7b..10b67d4f 100644 --- a/appTools/ToolAlignObjects.py +++ b/appTools/ToolAlignObjects.py @@ -80,20 +80,38 @@ class AlignObjects(AppTool): self.app.defaults.report_usage("ToolAlignObjects()") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolCalculators.py b/appTools/ToolCalculators.py index 9840e329..0bbf14e0 100644 --- a/appTools/ToolCalculators.py +++ b/appTools/ToolCalculators.py @@ -48,20 +48,38 @@ class ToolCalculator(AppTool): self.app.defaults.report_usage("ToolCalculators()") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolCalibration.py b/appTools/ToolCalibration.py index 42646e11..7409bd03 100644 --- a/appTools/ToolCalibration.py +++ b/appTools/ToolCalibration.py @@ -90,20 +90,38 @@ class ToolCalibration(AppTool): self.app.defaults.report_usage("ToolCalibration()") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolCopperThieving.py b/appTools/ToolCopperThieving.py index 146e3819..bc9d7855 100644 --- a/appTools/ToolCopperThieving.py +++ b/appTools/ToolCopperThieving.py @@ -101,20 +101,38 @@ class ToolCopperThieving(AppTool): self.app.defaults.report_usage("ToolCopperThieving()") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolCorners.py b/appTools/ToolCorners.py index 4ccc087b..3671055b 100644 --- a/appTools/ToolCorners.py +++ b/appTools/ToolCorners.py @@ -67,20 +67,38 @@ class ToolCorners(AppTool): self.app.defaults.report_usage("ToolCorners()") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolCutOut.py b/appTools/ToolCutOut.py index 3c29cae5..29a1efea 100644 --- a/appTools/ToolCutOut.py +++ b/appTools/ToolCutOut.py @@ -135,20 +135,38 @@ class CutOut(AppTool): self.app.defaults.report_usage("ToolCutOut()") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolDblSided.py b/appTools/ToolDblSided.py index a1cf401f..093510c0 100644 --- a/appTools/ToolDblSided.py +++ b/appTools/ToolDblSided.py @@ -84,20 +84,38 @@ class DblSidedTool(AppTool): self.app.defaults.report_usage("Tool2Sided()") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolDrilling.py b/appTools/ToolDrilling.py index a42ab93a..f52aac7a 100644 --- a/appTools/ToolDrilling.py +++ b/appTools/ToolDrilling.py @@ -224,20 +224,38 @@ class ToolDrilling(AppTool, Excellon): log.debug("ToolDrilling().run() was launched ...") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolEtchCompensation.py b/appTools/ToolEtchCompensation.py index 70870ad8..cb8ac692 100644 --- a/appTools/ToolEtchCompensation.py +++ b/appTools/ToolEtchCompensation.py @@ -56,20 +56,38 @@ class ToolEtchCompensation(AppTool): log.debug("ToolEtchCompensation() is running ...") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolExtract.py b/appTools/ToolExtract.py index a11a9b34..d477c838 100644 --- a/appTools/ToolExtract.py +++ b/appTools/ToolExtract.py @@ -119,20 +119,38 @@ class ToolExtract(AppTool): self.app.defaults.report_usage("Extract Drills()") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolFiducials.py b/appTools/ToolFiducials.py index 9a3136aa..f2c07492 100644 --- a/appTools/ToolFiducials.py +++ b/appTools/ToolFiducials.py @@ -92,20 +92,38 @@ class ToolFiducials(AppTool): self.app.defaults.report_usage("ToolFiducials()") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolFilm.py b/appTools/ToolFilm.py index 287b3dbc..e0c24f32 100644 --- a/appTools/ToolFilm.py +++ b/appTools/ToolFilm.py @@ -86,20 +86,38 @@ class Film(AppTool): self.app.defaults.report_usage("ToolFilm()") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolFollow.py b/appTools/ToolFollow.py index c5f7c5e8..0909643d 100644 --- a/appTools/ToolFollow.py +++ b/appTools/ToolFollow.py @@ -81,20 +81,38 @@ class ToolFollow(AppTool, Gerber): log.debug("ToolFOllow().run() was launched ...") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolImage.py b/appTools/ToolImage.py index 3f0b5473..ecbfc877 100644 --- a/appTools/ToolImage.py +++ b/appTools/ToolImage.py @@ -43,20 +43,38 @@ class ToolImage(AppTool): self.app.defaults.report_usage("ToolImage()") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolInvertGerber.py b/appTools/ToolInvertGerber.py index 439212e1..0bbdb296 100644 --- a/appTools/ToolInvertGerber.py +++ b/appTools/ToolInvertGerber.py @@ -51,20 +51,38 @@ class ToolInvertGerber(AppTool): log.debug("ToolInvertGerber() is running ...") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolIsolation.py b/appTools/ToolIsolation.py index ddaedfe7..223e02b4 100644 --- a/appTools/ToolIsolation.py +++ b/appTools/ToolIsolation.py @@ -157,20 +157,38 @@ class ToolIsolation(AppTool, Gerber): log.debug("ToolIsolation().run() was launched ...") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolMilling.py b/appTools/ToolMilling.py index 1048d637..8e0ab971 100644 --- a/appTools/ToolMilling.py +++ b/appTools/ToolMilling.py @@ -155,20 +155,38 @@ class ToolMilling(AppTool, Excellon): log.debug("ToolMilling().run() was launched ...") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolNCC.py b/appTools/ToolNCC.py index e8ae09bf..5177322d 100644 --- a/appTools/ToolNCC.py +++ b/appTools/ToolNCC.py @@ -166,20 +166,38 @@ class NonCopperClear(AppTool, Gerber): log.debug("ToolNCC().run() was launched ...") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolOptimal.py b/appTools/ToolOptimal.py index ecd47480..22a95111 100644 --- a/appTools/ToolOptimal.py +++ b/appTools/ToolOptimal.py @@ -79,20 +79,38 @@ class ToolOptimal(AppTool): self.app.defaults.report_usage("ToolOptimal()") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolPaint.py b/appTools/ToolPaint.py index 0f4648a6..e87ee5f5 100644 --- a/appTools/ToolPaint.py +++ b/appTools/ToolPaint.py @@ -196,20 +196,38 @@ class ToolPaint(AppTool, Gerber): log.debug("ToolPaint().run() was launched ...") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolPanelize.py b/appTools/ToolPanelize.py index 66033aab..79a77bd6 100644 --- a/appTools/ToolPanelize.py +++ b/appTools/ToolPanelize.py @@ -66,20 +66,38 @@ class Panelize(AppTool): self.app.defaults.report_usage("ToolPanelize()") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolPcbWizard.py b/appTools/ToolPcbWizard.py index d79ab748..0a73f99d 100644 --- a/appTools/ToolPcbWizard.py +++ b/appTools/ToolPcbWizard.py @@ -69,20 +69,38 @@ class PcbWizard(AppTool): self.app.defaults.report_usage("PcbWizard Tool()") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolProperties.py b/appTools/ToolProperties.py index 028392fd..406ec7d2 100644 --- a/appTools/ToolProperties.py +++ b/appTools/ToolProperties.py @@ -75,20 +75,38 @@ class Properties(AppTool): return if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolPunchGerber.py b/appTools/ToolPunchGerber.py index 810dec76..4549fe3c 100644 --- a/appTools/ToolPunchGerber.py +++ b/appTools/ToolPunchGerber.py @@ -149,20 +149,38 @@ class ToolPunchGerber(AppTool, Gerber): self.app.defaults.report_usage("ToolPunchGerber()") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolQRCode.py b/appTools/ToolQRCode.py index 94f131e5..921f3b67 100644 --- a/appTools/ToolQRCode.py +++ b/appTools/ToolQRCode.py @@ -89,20 +89,38 @@ class QRCode(AppTool): self.app.defaults.report_usage("QRCode()") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolRulesCheck.py b/appTools/ToolRulesCheck.py index 15bf43a2..21a17db1 100644 --- a/appTools/ToolRulesCheck.py +++ b/appTools/ToolRulesCheck.py @@ -91,20 +91,38 @@ class RulesCheck(AppTool): self.app.defaults.report_usage("ToolRulesCheck()") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolSolderPaste.py b/appTools/ToolSolderPaste.py index bf607467..5775f517 100644 --- a/appTools/ToolSolderPaste.py +++ b/appTools/ToolSolderPaste.py @@ -91,20 +91,38 @@ class SolderPaste(AppTool): self.app.defaults.report_usage("ToolSolderPaste()") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolSub.py b/appTools/ToolSub.py index 4586d073..a95edab9 100644 --- a/appTools/ToolSub.py +++ b/appTools/ToolSub.py @@ -101,21 +101,58 @@ class ToolSub(AppTool): def run(self, toggle=True): self.app.defaults.report_usage("ToolSub()") + # if toggle: + # # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if self.app.ui.splitter.sizes()[0] == 0: + # self.app.ui.splitter.setSizes([1, 1]) + # else: + # try: + # if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: + # # if tab is populated with the tool but it does not have the focus, focus on it + # if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # # focus on Tool Tab + # self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + # else: + # self.app.ui.splitter.setSizes([0, 1]) + # except AttributeError: + # pass + # else: + # if self.app.ui.splitter.sizes()[0] == 0: + # self.app.ui.splitter.setSizes([1, 1]) + if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) diff --git a/appTools/ToolTransform.py b/appTools/ToolTransform.py index f8352c7e..47dbab64 100644 --- a/appTools/ToolTransform.py +++ b/appTools/ToolTransform.py @@ -61,20 +61,38 @@ class ToolTransform(AppTool): self.app.defaults.report_usage("ToolTransform()") if toggle: - # if the splitter is hidden, display it, else hide it but only if the current widget is the same + # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1]) - else: - try: - if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - # if tab is populated with the tool but it does not have the focus, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) - else: + + # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same + found_idx = None + for idx in range(self.app.ui.notebook.count()): + if self.app.ui.notebook.widget(idx).objectName() == "tool_tab": + found_idx = idx + break + # show the Tab + if not found_idx: + self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Tool")) + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + + try: + if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName and found_idx: + # if the Tool Tab is not focused, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + # else remove the Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) + self.app.ui.notebook.removeTab(2) + + # if there are no objects loaded in the app then hide the Notebook widget + if not self.app.collection.get_list(): self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass + except AttributeError: + pass else: if self.app.ui.splitter.sizes()[0] == 0: self.app.ui.splitter.setSizes([1, 1])