import FreeCADGui class MyWorkbench: MenuText = "My Workbench" ToolTip = "My custom workbench" FreeCADGui.addWorkbench(MyWorkbench())
import FreeCADGui from PySide import QtGui, QtCore class MyWorkbench: MenuText = "My Workbench" ToolTip = "My custom workbench" def __init__(self): self.toolbar = None def Initialize(self): self.toolbar = QtGui.QToolBar("My Toolbar") my_action = QtGui.QAction("Custom Action", self.toolbar) my_action.triggered.connect(self.run_script) self.toolbar.addAction(my_action) FreeCADGui.addToolBar(self.toolbar) def run_script(self): print('Hello from my custom workbench!') FreeCADGui.addWorkbench(MyWorkbench())In this example, we define a new class called "MyWorkbench" that includes an Initialize method that adds a custom toolbar to the FreeCAD interface. The toolbar includes a button with a custom action that runs a Python script when clicked. The run_script method simply prints a message to the console. Package Library: - FreeCADGui (from the FreeCAD package) - PySide (from the Qt package)