From 33d82d44dc8bba80bc38332d422d00a2d0b252ef Mon Sep 17 00:00:00 2001 From: vocx-fc Date: Sat, 29 Feb 2020 16:46:01 -0600 Subject: [PATCH] Draft: clean up gui_arrays and gui_base Small spacing fixes like imports in separate lines for more clarity, the module docstring, and the position of the license. Remove unused imports. And use proper `ToDo` class instead of importing `DraftGui`. --- src/Mod/Draft/draftguitools/gui_arrays.py | 19 +++++++++++-------- src/Mod/Draft/draftguitools/gui_base.py | 20 ++++++++++---------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/Mod/Draft/draftguitools/gui_arrays.py b/src/Mod/Draft/draftguitools/gui_arrays.py index 49a7f096f5..81bff17fbb 100644 --- a/src/Mod/Draft/draftguitools/gui_arrays.py +++ b/src/Mod/Draft/draftguitools/gui_arrays.py @@ -1,8 +1,3 @@ -"""Provide the Draft ArrayTools command to group the other array tools.""" -## @package gui_arrays -# \ingroup DRAFT -# \brief Provide the Draft ArrayTools command to group the other array tools. - # *************************************************************************** # * (c) 2020 Eliud Cabrera Castillo * # * * @@ -25,9 +20,14 @@ # * USA * # * * # *************************************************************************** +"""Provide the Draft ArrayTools command to group the other array tools.""" +## @package gui_arrays +# \ingroup DRAFT +# \brief Provide the Draft ArrayTools command to group the other array tools. +from PySide.QtCore import QT_TRANSLATE_NOOP + import FreeCAD as App import FreeCADGui as Gui -from PySide.QtCore import QT_TRANSLATE_NOOP class ArrayGroupCommand: @@ -49,8 +49,11 @@ class ArrayGroupCommand: 'ToolTip': QT_TRANSLATE_NOOP("Arch", _tooltip)} def IsActive(self): - """Be active only when a document is active.""" - return App.ActiveDocument is not None + """Return True when this command should be available.""" + if App.ActiveDocument: + return True + else: + return False Gui.addCommand('Draft_ArrayTools', ArrayGroupCommand()) diff --git a/src/Mod/Draft/draftguitools/gui_base.py b/src/Mod/Draft/draftguitools/gui_base.py index f307b67315..1a149cc8cc 100644 --- a/src/Mod/Draft/draftguitools/gui_base.py +++ b/src/Mod/Draft/draftguitools/gui_base.py @@ -1,9 +1,3 @@ -"""This module provides the Base object for all Draft Gui commands. -""" -## @package gui_base -# \ingroup DRAFT -# \brief This module provides the Base object for all Draft Gui commands. - # *************************************************************************** # * (c) 2009 Yorik van Havre * # * (c) 2010 Ken Cline * @@ -28,10 +22,14 @@ # * USA * # * * # *************************************************************************** +"""Provide the Base object for all Draft Gui commands.""" +## @package gui_base +# \ingroup DRAFT +# \brief This module provides the Base object for all Draft Gui commands. import FreeCAD as App import FreeCADGui as Gui -import DraftGui +import draftutils.todo as todo class GuiCommandBase: @@ -52,7 +50,7 @@ class GuiCommandBase: Each string in the list of strings represents a Python instruction which will be executed in a delayed fashion - by `DraftGui.todo.delayCommit()` + by `todo.ToDo.delayCommit()` :: list1 = ["a = FreeCAD.Vector()", "pl = FreeCAD.Placement()", @@ -69,6 +67,7 @@ class GuiCommandBase: >>> pl = FreeCAD.Placement() >>> Draft.autogroup(obj) """ + def __init__(self): self.call = None self.commit_list = [] @@ -78,7 +77,8 @@ class GuiCommandBase: self.planetrack = None def IsActive(self): - if Gui.ActiveDocument: + """Return True when this command should be available.""" + if App.ActiveDocument: return True else: return False @@ -102,7 +102,7 @@ class GuiCommandBase: pass self.call = None if self.commit_list: - DraftGui.todo.delayCommit(self.commit_list) + todo.ToDo.delayCommit(self.commit_list) self.commit_list = [] def commit(self, name, func):