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`.
This commit is contained in:
@@ -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 <e.cabrera-castillo@tum.de> *
|
||||
# * *
|
||||
@@ -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())
|
||||
|
||||
@@ -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 <yorik@uncreated.net> *
|
||||
# * (c) 2010 Ken Cline <cline@frii.com> *
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user