python Toggle buttons visability

   567   3   1
User Avatar
Member
22 posts
Joined: Oct. 2012
Offline
Hey
I have two buttons in hda's UI one to 'Start paint' and the other 'Done paint' I want each one to toggle the other visibility so they are not shown together, I been digging around with no success can someone point me for a good tip please
thank you
User Avatar
Member
46 posts
Joined: Dec. 2014
Offline
You could use a hidden toggle parm in the "hide when" and then use a bit of python in the buttons callback to turn said toggle parm off and on.
User Avatar
Member
22 posts
Joined: Oct. 2012
Offline
OK this could make sense but can you explain it more please?
User Avatar
Member
46 posts
Joined: Dec. 2014
Offline
First create a toggle parm and name it "button_toggle".

In the 2 buttons put in the "Hide When" section this { button_toggle == 0 }changing the 0 to a 1 in the second button parm.

If this is a HDA:

In both button parms put this in the Callback Script(Set to Python) hou.phm().toggle_button(kwargs)
Then go to the Scripts tab and add a Python Module and paste this.
def toggle_button(kwargs):
    node = kwargs["node"]
    toggle = node.evalParm("button_toggle")
    node.parm("button_toggle").set(1-toggle)

If this is not a HDA or you want it to be less clean.

In both button parms put this in the Callback Script.
node = kwargs["node"];
toggle = node.evalParm("button_toggle");
node.parm("button_toggle").set(1-toggle)
Edited by JohnDoe777 - June 30, 2025 14:05:01
  • Quick Links