framework/sequence_generation/InitGui.py
2024-03-24 15:26:20 +03:00

45 lines
2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import FreeCAD
import FreeCADGui
def register_commands(commands_dict):
for cmd_name, (func, icon_path) in commands_dict.items():
FreeCADGui.addCommand(cmd_name, func)
FreeCADGui.addIcon(cmd_name + "_icon", icon_path)
class MyWorkbenchGui:
def Initialize(self):
pass
def InitGui(self):
# Словарь с именами функций и путями к иконкам
commands_dict = {
'Check Model': (my_function1, "Path/to/icon1.svg"),
'Constraints Autogeneration': (my_function2, "Path/to/icon2.svg"),
'Constraints Editing': (my_function1, "Path/to/icon1.svg"),
'Generate AdjMatrix': (my_function1, "Path/to/icon1.svg"),
'Generate Relationship Matrix': (my_function1, "Path/to/icon1.svg"),
'Clusterisation': (my_function1, "Path/to/icon1.svg"),
'StepByStepClusterisation': (my_function1, "Path/to/icon1.svg"),
'Generate Assembly Sequences': (my_function1, "Path/to/icon1.svg"),
'Decomposition Step': (my_function1, "Path/to/icon1.svg")
}
# Регистрация команд и иконок
register_commands(commands_dict)
# Создание панели инструментов и добавление команд с иконками
self.appendToolbar("Preprocessing", ["Check Model", "Constraints Autogeneration", "Constraints Editing"])
self.appendToolbar("Analysis", ["Generate AdjMatrix", "Generate Relationship Matrix", "Clusterisation", "StepByStepClusterisation"])
self.appendToolbar("AssemblySequence", ["Generate Assembly Sequences", "Decomposition Step" ])
def appendToolbar(self, toolbar_name, commands):
toolbar = FreeCADGui.ToolBar(toolbar_name)
for cmd, icon in commands:
toolbar.appendCommand(cmd, icon)
# Создание экземпляра верстака GUI
my_workbench_gui = MyWorkbenchGui()
# Регистрация верстака
FreeCADGui.addWorkbench(my_workbench_gui)