[Solved] Accessing FreeCAD custom widgets from Python

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
chennes
Veteran
Posts: 3881
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

[Solved] Accessing FreeCAD custom widgets from Python

Post by chennes »

I'd like to be able to instantiate some of FreeCAD's custom widgets (those defined in Widgets.h/Widgets.cpp) from Python. Is this currently possible? (In particular, I want a UrlLabel)
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Accessing FreeCAD custom widgets from Python

Post by TheMarkster »

Code: Select all

import FreeCADGui
ui=FreeCADGui.UiLoader()
w=ui.createWidget("Gui::UrlLabel")
w.setText("Click me")
w.setUrl("http://www.freecadweb.org")
w.show()
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Accessing FreeCAD custom widgets from Python

Post by openBrain »

I remember Draft also extensively uses 'Gui::InputField' widgets. Could give some more clues.
User avatar
chennes
Veteran
Posts: 3881
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Accessing FreeCAD custom widgets from Python

Post by chennes »

TheMarkster wrote: Mon Oct 18, 2021 5:59 am .
That's perfect, thanks!
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
Post Reply