def New(): doc = FreeCAD.activeDocument() if doc == None: doc = FreeCAD.newDocument() a = doc.addObject("Part::FeaturePython", "Line") Geometric(a) a.ViewObject.Proxy = 0 doc.recompute() FreeCADGui.getWorkbench("GDTWB").monitor.append( a.link.Name, a.Name, FreeCAD.ActiveDocument.removeObject, a.Name) return a
def onChanged(self, fp, prop): '''Do something when a property has changed''' #FreeCAD.Console.PrintMessage("** on Changed " + fp.Name + " : " + prop + "\n") if prop == 'link': if not fp.link: #FreeCAD.Console.PrintMessage("Link removed\n") return #FreeCAD.Console.PrintMessage("Change the link " + fp.link.Name + '\n') self.execute(fp) FreeCAD.activeDocument().recompute() FreeCADGui.getWorkbench("GDTWB").monitor.remap( self.oldName, fp.link.Name, fp.Name) return
def setUp(self): FreeCAD.Console.PrintLog('Setup Test menu...\n') list = [ "Test_TestAll", "Test_TestDoc", "Test_TestBase", "Test_TestWork" ] w = FreeCADGui.getWorkbench('TestWorkbench') w.appendMenu("TestMenu", list)
def testMenu(self): # check menu for items FreeCAD.Console.PrintLog('Checking Test menu...\n') w = FreeCADGui.getWorkbench('TestWorkbench') list = w.listMenus() self.b = True for i in list: if i == 'TestMenu': self.b = False self.failUnless(self.b == True, "Test menu still added")
def testMenu(self): # check menu for items FreeCAD.Console.PrintLog ('Checking Test menu...\n') w = FreeCADGui.getWorkbench('TestWorkbench') list = w.listMenus() self.b = True for i in list: if i == 'TestMenu': self.b=False self.failUnless(self.b==True,"Test menu still added")
def refreshComboWB(self): if 'PathWorkbench' in FreeCADGui.listWorkbenches(): wb = FreeCADGui.getWorkbench('PathWorkbench') if hasattr(wb, '__Workbench__'): MachinekitPreferences.Setup() mks = {} for mk in [ mk for mk in machinekit.Instances() if mk.isValid() ]: if self.comboTB.get(mk) is None: name = "%s_%d" % (MachinekitCommandCombo.__name__, self.comboID) cmd = MachinekitCommandCombo(mk) self._addCommand(name, cmd) mks[mk] = (name, cmd) self.comboID = self.comboID + 1 else: mks[mk] = self.comboTB[mk] tb = FreeCADGui.getMainWindow().findChild( PySide.QtGui.QToolBar, 'MachinekitCombo') if tb: # first remove all tool buttons which are no longer valid for mk in [mk for mk in self.comboTB if not mk in mks]: actions = tb.actions() for action in actions: if action.text() == mk.name(): PathLog.track('removing', mk.name()) tb.removeAction(action) for mk in [mk for mk in mks if not mk in self.comboTB]: icon = machinekit.IconResource('machinekiticon.svg') PathLog.track('adding', mk.name()) tb.addAction(icon, mk.name(), mks[mk][1].Activated) elif mks: if 'PathWorkbench' == FreeCADGui.activeWorkbench().name(): PathLog.track('createToolbar') tb = PySide.QtGui.QToolBar() tb.setObjectName('MachinekitCombo') for mk in [mk for mk in mks if not mk in self.comboTB]: icon = machinekit.IconResource( 'machinekiticon.svg') PathLog.track('adding+', mk.name(), icon) tb.addAction(icon, mk.name(), mks[mk][1].Activated) FreeCADGui.getMainWindow().addToolBar(tb) tools = [mks[mk][0] for mk in mks] PathLog.track('appendToolbar', tools) wb.appendToolbar('MachinekitCombo', tools) self.comboTB = mks else: PathLog.track('no __Workbench__')
def setUp(self): FreeCAD.Console.PrintLog('Remove Test menu...\n') w = FreeCADGui.getWorkbench('TestWorkbench') w.removeMenu("TestMenu")
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. # # ################################################################################### import FreeCADGui import os import fcpdwb_locator fcpdWBpath = os.path.dirname(fcpdwb_locator.__file__) fcpdWB_icons_path = os.path.join(fcpdWBpath, 'Icons') global FCPDwb FCPDwb = FreeCADGui.getWorkbench('FCPDWorkbench') class FCPD_CommandRun(): """Run PDServer""" global FCPDwb def GetResources(self): return { 'Pixmap': os.path.join(fcpdWB_icons_path, 'start.png'), 'MenuText': "Run Pure-Data server", 'ToolTip': "Run the internal server and let Pure-Data to connect to." }
def setUp(self): FreeCAD.Console.PrintLog ('Remove Test menu...\n') w = FreeCADGui.getWorkbench('TestWorkbench') w.removeMenu("TestMenu")
def setUp(self): FreeCAD.Console.PrintLog ('Setup Test menu...\n') list = ["Test_TestAll","Test_TestDoc","Test_TestBase","Test_TestWork"] w = FreeCADGui.getWorkbench('TestWorkbench') w.appendMenu("TestMenu",list)