[Solved]command button is clickable under certain conditions

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
xianyu
Posts: 66
Joined: Mon Jun 27, 2022 7:34 am

[Solved]command button is clickable under certain conditions

Post by xianyu »

Hi~
I created three command buttons in the toolbar. I want to achieve this when I click on the first and second buttons. The third button can be clicked (by default, it cannot be clicked, the icon is gray).

I plan to write code for IsActive () on the third button, but I realize that the IsActive function has already been "initialized" in the beginning. How can I implement this function?
Thanks in advance!
Last edited by xianyu on Tue May 23, 2023 6:22 am, edited 1 time in total.
Freecad novice, A Python enthusiast
marioalexis
Posts: 124
Joined: Wed Jun 19, 2019 7:44 pm

Re: command button is clickable under certain conditions

Post by marioalexis »

You can use the Gui.CommandAction descriptor class.
Here is an example of how you can use it: https://github.com/FreeCAD/FreeCAD/pull/9171
xianyu
Posts: 66
Joined: Mon Jun 27, 2022 7:34 am

Re: command button is clickable under certain conditions

Post by xianyu »

marioalexis wrote: Mon May 22, 2023 7:53 pm You can use the Gui.CommandAction descriptor class.
Here is an example of how you can use it: https://github.com/FreeCAD/FreeCAD/pull/9171
Thank you, marioalexis. I think I found a solution
Freecad novice, A Python enthusiast
Post Reply