Skip to content

Commit

Permalink
Draft: clean up gui_arrays and gui_base
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
vocx-fc authored and yorikvanhavre committed Apr 7, 2020
1 parent cf7b774 commit 43c93b8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
19 changes: 11 additions & 8 deletions 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 <e.cabrera-castillo@tum.de> *
# * *
Expand All @@ -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:
Expand All @@ -49,8 +49,11 @@ def GetResources(self):
'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())
20 changes: 10 additions & 10 deletions 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 <yorik@uncreated.net> *
# * (c) 2010 Ken Cline <cline@frii.com> *
Expand All @@ -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:
Expand All @@ -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()",
Expand All @@ -69,6 +67,7 @@ class GuiCommandBase:
>>> pl = FreeCAD.Placement()
>>> Draft.autogroup(obj)
"""

def __init__(self):
self.call = None
self.commit_list = []
Expand All @@ -78,7 +77,8 @@ def __init__(self):
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
Expand All @@ -102,7 +102,7 @@ def finish(self):
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):
Expand Down

0 comments on commit 43c93b8

Please sign in to comment.