Is it possible to change an Icon of a Combo view object?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
easyw-fc
Veteran
Posts: 3629
Joined: Thu Jul 09, 2015 9:34 am

Is it possible to change an Icon of a Combo view object?

Post by easyw-fc »

Hi,
is it possible to change an icon of a combo view object with python code?
combo.png
combo.png (9.84 KiB) Viewed 1091 times
User avatar
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?

Post by DeepSOIC »

Yes. Reimplement getIcon method of viewprovider:

Code: Select all

class ViewProviderSomething:
    ...
    def getIcon(self):
        return ":/icons/PartDesign_Body_Tree.svg"
User avatar
Chris_G
Veteran
Posts: 2579
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Is it possible to change an Icon of a Combo view object?

Post by Chris_G »

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 :
icons.jpeg
icons.jpeg (8.86 KiB) Viewed 1002 times
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 ...
Post Reply