InitGui.py
1 # -*- coding: utf-8 -*-
2 
3 # ***************************************************************************
4 # * *
5 # * Animate workbench - FreeCAD Workbench for lightweight animation *
6 # * Copyright (c) 2019 Jiří Valášek jirka362@gmail.com *
7 # * *
8 # * This file is part of the Animate workbench. *
9 # * *
10 # * This program is free software; you can redistribute it and/or modify *
11 # * it under the terms of the GNU Lesser General Public License (LGPL) *
12 # * as published by the Free Software Foundation; either version 2 of *
13 # * the License, or (at your option) any later version. *
14 # * for detail see the LICENCE text file. *
15 # * *
16 # * Animate workbench is distributed in the hope that it will be useful, *
17 # * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 # * GNU Lesser General Public License for more details. *
20 # * *
21 # * You should have received a copy of the GNU Library General Public *
22 # * License along with Animate workbench; if not, write to the Free *
23 # * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
24 # * MA 02111-1307 USA *
25 # * *
26 # ***************************************************************************/
27 
28 
35 
36 import FreeCAD
37 import FreeCADGui
38 
39 
40 
48 
49 class Animate(FreeCADGui.Workbench):
50 
51 
53 
54 
56 
57 
59 
60 
62 
63 
71 
72  def __init__(self):
73  import os
74  self.__class__.Icon = os.path.join(FreeCAD.getHomePath(), "Mod",
75  "Animate", "Resources", "Icons",
76  "Animate.png")
77  self.__class__.MenuText = "Animate"
78  self.__class__.ToolTip = "Animation workbench"
79 
80 
88 
89  def Initialize(self):
90  # import here all the needed files that create your FreeCAD commands
91  import Server
92  import Control
93  import Trajectory
94  import CollisionDetector
95  import RobWorld
96  import RobRotation
97  import RobTranslation
98  # A list of command names created in the line above
99  self.list = ["ServerCommand", "ControlCommand", "TrajectoryCommand",
100  "CollisionDetectorCommand", "RobWorldCommand",
101  "RobRotationCommand", "RobTranslationCommand"]
102  # creates a new toolbar with your commands
103  self.appendToolbar("Animate", self.list)
104  # creates a new menu
105  self.appendMenu("Animate", self.list[:4])
106  # appends a submenu to an existing menu
107  self.appendMenu(["Animate", "Robotics"], self.list[4:])
108 
109 
113 
114  def Activated(self):
115  FreeCAD.Console.PrintMessage("Animate workbench activated\n")
116 
117 
121 
122  def Deactivated(self):
123  FreeCAD.Console.PrintMessage("Animate workbench deactivated\n")
124 
125 
133 
134  def ContextMenu(self, recipient):
135  # Log who is the recipient
136  # FreeCAD.Console.PrintLog("Preparing context menu for " + recipient
137  # + "\n")
138  # Add commands to the context menu if necessary
139  # self.appendContextMenu("My commands", self.list)
140  pass
141 
142 
147 
148  def GetClassName(self):
149  return "Gui::PythonWorkbench"
150 
151 
152 FreeCADGui.addWorkbench(Animate())
Animate workbench class according to the PythonWorkbench template.
Definition: InitGui.py:49
def Activated(self)
This function is executed when the workbench is activated.
Definition: InitGui.py:114
def GetClassName(self)
Mandatory method for full python workbenches.
Definition: InitGui.py:148
list
A list of str which are the names of imported commands.
Definition: InitGui.py:99
def ContextMenu(self, recipient)
Method to add custom commands to a context menu with respect to a recipient.
Definition: InitGui.py:134
def Initialize(self)
Method used to setup workbench upon being selected on the workbench toolbar.
Definition: InitGui.py:89
def Deactivated(self)
This function is executed when the workbench is deactivated.
Definition: InitGui.py:122
def __init__(self)
Initialization method for Animate workbench.
Definition: InitGui.py:72