How to update view using 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
xc22143
Posts: 139
Joined: Fri Dec 03, 2021 9:52 am

How to update view using python

Post by xc22143 »

Hello, everyone.

I am creating a panel. I want to update the view whenever the value is changed, like the 'PartDesign-pad' panel.
image_74.png
image_74.png (17.21 KiB) Viewed 632 times
How to add the update view using python API? Thank you!
edi
Posts: 481
Joined: Fri Jan 17, 2020 1:32 pm

Re: How to update view using python

Post by edi »

To update changes whenever something happened (a button pressed in the panel) in the user interface, you need a viewprovider.

- Create a custom viewprovider and connect it to an object: https://wiki.freecadweb.org/Viewprovider.
- Connect buttons in your panel to slots in your viewprovider.

I think it should work, but I did not test it.
User avatar
ebrahim raeyat
Posts: 619
Joined: Sun Sep 09, 2018 7:00 pm
Location: Iran
Contact:

Re: How to update view using python

Post by ebrahim raeyat »

you can view my implementation for creating steel column section:

https://github.com/ebrahimraeyat/momen/ ... on.py#L330

the section update in this function:

https://github.com/ebrahimraeyat/momen/ ... on.py#L356
mario52
Veteran
Posts: 4673
Joined: Wed May 16, 2012 2:13 pm

Re: How to update view using python

Post by mario52 »

Hi

Code: Select all

Gui.updateGui()                                        # rafraichi l'ecran

# or
FreeCADGui.updateGui()                                 # rafraichi l'ecran

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
Post Reply