How to show message on preferences changed

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
mpetrasinovic
Posts: 106
Joined: Sat Feb 22, 2020 10:19 am
Location: Belgrade, Serbia
Contact:

How to show message on preferences changed

Post by mpetrasinovic »

As a part of the custom workbench, I would like to inform a user when the value of the parameter in preference dialog for this workbench is changed that FreeCAD needs to be restarted. I could not find any python workbench with similar functionality implemented. Is there an easy way to do this from python?
mario52
Veteran
Posts: 4701
Joined: Wed May 16, 2012 2:13 pm

Re: How to show message on preferences changed

Post by mario52 »

hi

here examples for read an save parameter

1: How do I get parameters to match.

2: How do I get parameters to match

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.
User avatar
mpetrasinovic
Posts: 106
Joined: Sat Feb 22, 2020 10:19 am
Location: Belgrade, Serbia
Contact:

Re: How to show message on preferences changed

Post by mpetrasinovic »

Hi mario,

Thank you for your response, but I need a way to call a function when the user changes the value of the parameter. I am not sure if there is a way to implement this callback.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: How to show message on preferences changed

Post by openBrain »

You can connect slots to preferences input field signals and trigger an action accordingly.
User avatar
mpetrasinovic
Posts: 106
Joined: Sat Feb 22, 2020 10:19 am
Location: Belgrade, Serbia
Contact:

Re: How to show message on preferences changed

Post by mpetrasinovic »

openBrain wrote: Sat Mar 28, 2020 12:18 pm You can connect slots to preferences input field signals and trigger an action accordingly.
Could you please provide a code example for this?
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: How to show message on preferences changed

Post by openBrain »

mpetrasinovic wrote: Sat Mar 28, 2020 2:34 pm Could you please provide a code example for this?
Please give details. Which parameter? Which workbench?
User avatar
mpetrasinovic
Posts: 106
Joined: Sat Feb 22, 2020 10:19 am
Location: Belgrade, Serbia
Contact:

Re: How to show message on preferences changed

Post by mpetrasinovic »

I would like to implement this in my custom workbench (I will publish it soon). But I would like to see how to implement this for an input field in preferences from python.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: How to show message on preferences changed

Post by openBrain »

mpetrasinovic wrote: Sat Mar 28, 2020 2:52 pm I would like to implement this in my custom workbench (I will publish it soon). But I would like to see how to implement this for an input field in preferences from python.
Why just not write it in the preference dialog : something like "Need application restart" ? :?:
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to show message on preferences changed

Post by Kunda1 »

mpetrasinovic wrote: Fri Mar 27, 2020 6:56 pm As a part of the custom workbench, I would like to inform a user when the value of the parameter in preference dialog for this workbench is changed that FreeCAD needs to be restarted. I could not find any python workbench with similar functionality implemented. Is there an easy way to do this from python?
This would also benefit the Addon Manager (https://github.com/FreeCAD/FreeCAD-addons/issues/95)
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
mpetrasinovic
Posts: 106
Joined: Sat Feb 22, 2020 10:19 am
Location: Belgrade, Serbia
Contact:

Re: How to show message on preferences changed

Post by mpetrasinovic »

openBrain wrote: Sat Mar 28, 2020 3:53 pm Why just not write it in the preference dialog : something like "Need application restart" ? :?:
This is the way it is now, but I think it would be better for users to open the message box if that is possible.
Post Reply