InitGui.Animate Class Reference

Animate workbench class according to the PythonWorkbench template. More...

Inheritance diagram for InitGui.Animate:

Public Member Functions

def __init__ (self)
 Initialization method for Animate workbench. More...
 
def Initialize (self)
 Method used to setup workbench upon being selected on the workbench toolbar. More...
 
def Activated (self)
 This function is executed when the workbench is activated. More...
 
def Deactivated (self)
 This function is executed when the workbench is deactivated. More...
 
def ContextMenu (self, recipient)
 Method to add custom commands to a context menu with respect to a recipient. More...
 
def GetClassName (self)
 Mandatory method for full python workbenches. More...
 

Public Attributes

 list
 A list of str which are the names of imported commands. More...
 

Detailed Description

Animate workbench class according to the PythonWorkbench template.

This class represents the workbench in the FreeCAD Gui i.e. it imports commands, shows them on a toolbar and in a menu when workbench is activated. It contains information to make and item in the workbench toolbar listbox.

Definition at line 49 of file InitGui.py.

Constructor & Destructor Documentation

◆ __init__()

def InitGui.Animate.__init__ (   self)

Initialization method for Animate workbench.

A class instance is created, an static attributes Icon, MenuText and ToolTip are added to the class. The Icon is a path to an image to be shown on the workbench toolbar. The MenuText is a str text to be shown in the listbox on the workbench toolbar. The ToolTip is a str tooltip for the Animate workbench.

Definition at line 72 of file InitGui.py.

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 

Member Function Documentation

◆ Activated()

def InitGui.Animate.Activated (   self)

This function is executed when the workbench is activated.

For now it's used just to inform a user about the fact via console message.

Definition at line 114 of file InitGui.py.

114  def Activated(self):
115  FreeCAD.Console.PrintMessage("Animate workbench activated\n")
116 
def Activated(self)
Method used as a callback when the toolbar button or the menu item is clicked.
Definition: Trajectory.py:1575

◆ ContextMenu()

def InitGui.Animate.ContextMenu (   self,
  recipient 
)

Method to add custom commands to a context menu with respect to a recipient.

This method is executed whenever the user right-clicks in a Tree View or the View box. It's possible to only add commands via self.appendContextMenu().

Parameters
recipientA str equal to "Tree" or "View" according to where user clicked.

Definition at line 134 of file InitGui.py.

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 

◆ Deactivated()

def InitGui.Animate.Deactivated (   self)

This function is executed when the workbench is deactivated.

For now it's used just to inform a user about the fact via console message.

Definition at line 122 of file InitGui.py.

122  def Deactivated(self):
123  FreeCAD.Console.PrintMessage("Animate workbench deactivated\n")
124 

◆ GetClassName()

def InitGui.Animate.GetClassName (   self)

Mandatory method for full python workbenches.

Returns
A str with C++ binding class for this workbench.

Definition at line 148 of file InitGui.py.

148  def GetClassName(self):
149  return "Gui::PythonWorkbench"
150 
151 
152 FreeCADGui.addWorkbench(Animate())

◆ Initialize()

def InitGui.Animate.Initialize (   self)

Method used to setup workbench upon being selected on the workbench toolbar.

This function is executed when user clicks on Animate workbench in the workbench listbox situated on the workbench toolbar. After that commands are added to the FreeCAD Gui by importing their modules. The names of imported commands are then saved in the list attribute. Afterwards a toolbar and a menu with some of those commands are created.

Definition at line 89 of file InitGui.py.

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 

Member Data Documentation

◆ list

InitGui.Animate.list

A list of str which are the names of imported commands.

Definition at line 99 of file InitGui.py.


The documentation for this class was generated from the following file: