Hi,
is it possible to change an icon of a combo view object with python code?
Is it possible to change an Icon of a Combo view object?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Is it possible to change an Icon of a Combo view object?
Yes. Reimplement getIcon method of viewprovider:
Code: Select all
class ViewProviderSomething:
...
def getIcon(self):
return ":/icons/PartDesign_Body_Tree.svg"
Re: Is it possible to change an Icon of a Combo view object?
I did a little bit of experiment with the icon recently here : Mirror Layer
The very first function of the macro, createIcon(color, override, mirror), returns a svg string, with custom color and aspect : The getIcon() function, near the end of the macro, returns an icon from the svg string ( self.icon ) using a temp file ( found the trick on this forum ).
Unfortunately, I have not found a way to ask for icon update, from within the FeaturePython object ...
So the Icon update needs a hide / show of the object with spacebar.
Customizable icons, that would be a cool feature ...
The very first function of the macro, createIcon(color, override, mirror), returns a svg string, with custom color and aspect : The getIcon() function, near the end of the macro, returns an icon from the svg string ( self.icon ) using a temp file ( found the trick on this forum ).
Unfortunately, I have not found a way to ask for icon update, from within the FeaturePython object ...
So the Icon update needs a hide / show of the object with spacebar.
Customizable icons, that would be a cool feature ...