add template for Python workbench

This commit is contained in:
wmayer
2016-10-04 19:29:53 +02:00
parent 7b70711fb3
commit 034cc0013e
8 changed files with 248 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
IF (BUILD_GUI)
PYSIDE_WRAP_RC(_TEMPLATEPY__QRC_SRCS Resources/_TEMPLATEPY_.qrc)
ENDIF (BUILD_GUI)
SET(_TEMPLATEPY__SRCS
Init.py
InitGui.py
_TEMPLATEPY_.py
_TEMPLATEPY_Gui.py
)
SOURCE_GROUP("" FILES ${_TEMPLATEPY__SRCS})
ADD_CUSTOM_TARGET(_TEMPLATEPY_ ALL
SOURCES ${_TEMPLATEPY__SRCS} ${_TEMPLATEPY__QRC_SRCS}
)
fc_copy_sources(_TEMPLATEPY_ "${CMAKE_BINARY_DIR}/Mod/_TEMPLATEPY_" ${_TEMPLATEPY__SRCS})
IF (BUILD_GUI)
fc_target_copy_resource(_TEMPLATEPY_
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_BINARY_DIR}/Mod/_TEMPLATEPY_
_TEMPLATEPY__rc.py)
ENDIF (BUILD_GUI)
INSTALL(
FILES
${_TEMPLATEPY__SRCS}
${_TEMPLATEPY__QRC_SRCS}
DESTINATION
Mod/_TEMPLATEPY_
)
SET(_TEMPLATEPY_GuiIcon_SVG
Resources/icons/_TEMPLATEPY_Workbench.svg
)
fc_copy_sources(_TEMPLATEPY_ "${CMAKE_BINARY_DIR}/Mod/_TEMPLATEPY_" ${_TEMPLATEPY_GuiIcon_SVG})
INSTALL(FILES ${_TEMPLATEPY_GuiIcon_SVG} DESTINATION "Mod/_TEMPLATEPY_/Resources/icons")

View File

@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# FreeCAD init script of the _TEMPLATEPY_ module
# (c) 2001 Juergen Riegel
# License LGPL

View File

@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# _TEMPLATEPY_ gui init module
# (c) 2001 Juergen Riegel
# License LGPL
class _TEMPLATEPY_Workbench ( Workbench ):
"_TEMPLATEPY_ workbench object"
Icon = FreeCAD.getHomePath() + "Mod/_TEMPLATEPY_/Resources/icons/_TEMPLATEPY_Workbench.svg"
MenuText = "_TEMPLATEPY_"
ToolTip = "_TEMPLATEPY_ workbench"
def Initialize(self):
# load the module
import _TEMPLATEPY_Gui
self.appendToolbar('_TEMPLATEPY_',['_TEMPLATEPY__HelloWorld'])
self.appendMenu('_TEMPLATEPY_',['_TEMPLATEPY__HelloWorld'])
def GetClassName(self):
return "Gui::PythonWorkbench"
Gui.addWorkbench(_TEMPLATEPY_Workbench())

View File

@@ -0,0 +1,5 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>icons/_TEMPLATEPY_Workbench.svg</file>
</qresource>
</RCC>

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@@ -0,0 +1,3 @@
/** \defgroup TEMPLATE _TEMPLATEPY_
* \ingroup WORKBENCHES */

View File

View File

@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# FreeCAD tools of the _TEMPLATEPY_ workbench
# (c) 2001 Juergen Riegel
# License LGPL
import FreeCAD, FreeCADGui
class CmdHelloWorld:
def Activated(self):
FreeCAD.Console.PrintMessage("Hello, World!\n")
def IsActive(self):
return True
def GetResources(self):
return {'Pixmap': 'freecad', 'MenuText': 'Hello World', 'ToolTip': 'Print Hello World'}
FreeCADGui.addCommand('_TEMPLATEPY__HelloWorld', CmdHelloWorld())