I tried to create an icon from XMP by different ways, but nothing works, but the workbench icon is displayed normally.
Log results when icon is loading to toolbar:
Although wiki example tell's that is possible... May be something broken in the source code?Cannot find icon:
/* XPM */
static const char * ViewProviderBox_xpm[] = {
"16 16 6 1",
Code: Select all
import FreeCAD, FreeCADGui
IconGlobal = """
/* XPM */
static const char * ViewProviderBox_xpm[] = {
"16 16 6 1",
" c None",
". c #141010",
"+ c #615BD2",
"@ c #C39D55",
"# c #000000",
"$ c #57C355",
" ........",
" ......++..+..",
" .@@@@.++..++.",
" .@@@@.++..++.",
" .@@ .++++++.",
" ..@@ .++..++.",
"###@@@@ .++..++.",
"##$.@@$#.++++++.",
"#$#$.$$$........",
"#$$####### ",
"#$$#$$$$$# ",
"#$$#$$$$$# ",
"#$$#$$$$$# ",
" #$#$$$$$# ",
" ##$$$$$# ",
" ####### "};
"""
class MyTool:
"""Explanation of the command."""
def __init__(self):
"""Initialize variables for the command that must exist at all times."""
pass
def GetResources(self):
return {"MenuText": "My Command",
"Accel": "Ctrl+M",
"ToolTip": "ToolTip command",
"Pixmap" : IconGlobal}
def Activated(self):
# do something here...
print("Activated")
def IsActive(self):
if FreeCAD.ActiveDocument == None:
return False
else:
return True
# The commands must be "registered" with a unique name by calling its class.
FreeCADGui.addCommand('My_Command1', MyTool())
FreeCADGui.addCommand('My_Command2', MyTool())
FreeCADGui.addCommand('My_Command3', MyTool())
class MyWorkbench ( Workbench ):
"My workbench object"
Icon = IconGlobal
MenuText = "My Workbench"
ToolTip = "This is workbench"
def GetClassName(self):
return "Gui::PythonWorkbench"
def Initialize(self):
self.appendToolbar("My Tools", ["My_Command1","My_Command2","My_Command3"])
self.appendMenu("My Tools", ["My_Command1","My_Command2","My_Command3"])
Log ("Loading MyModule... done\n")
def Activated(self):
# do something here if needed...
Msg ("MyWorkbench.Activated()\n")
def Deactivated(self):
# do something here if needed...
Msg ("MyWorkbench.Deactivated()\n")
FreeCADGui.addWorkbench(MyWorkbench)