A solution without writing to a hard drive is was not found yet?
For example, loading icons from SVG tags text string is perfect when workbench are use two single icons that have a difference only in fill color.
Then you can create one icon, and create the second one based on the first one, simply by changing the fill color in one of the SVG tags.
This can save a little bit of hard disk space when optimizing icons by this way.
I think this method of loading icons would be nice to have.
Icons in macros
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Icons in macros
Could you show me how to make the example listed below work without add icon to hard drive by temporary path? If that is possible...wmayer wrote: ↑Mon Jun 13, 2016 8:04 amYou can try Qt's resource system. In FreeCAD we use this heavily to embed resources (icons, translation files, ...) into the binaries. It can be used with C++ and Python. In case of Python I think it should be possible to add the generated code into your macro.Do you know any solution with a virtual file system in memory? I think, I have seen something, where all the path where retrieved from a resource-file loaded into memory.
Code: Select all
class MyWorkbench ( Workbench ):
"My workbench object"
Icon = """
/* SVG */
static const char *test_icon[]={
"<svg xmlns="http://www.w3.org/2000/svg" height="64" width="64">"
"<rect height="64" width="64" fill="#204a87" />"
"</svg>"};
"""
MenuText = "My Workbench"
ToolTip = "This is example of workbench creation basics"
def GetClassName(self):
return "Gui::PythonWorkbench"
def Initialize(self):
Log ("Loading ToolBar... done\n")
def Activated(self):
Msg ("MyWorkbench.Activated()\n")
def Deactivated(self):
Msg ("MyWorkbench.Deactivated()\n")
FreeCADGui.addWorkbench(MyWorkbench)