Python Callback issue

   2604   3   2
User Avatar
Member
34 posts
Joined: Sept. 2013
Offline
Hey Guys,

I am trying to execute functions from inside a string on click of buttons.I was able to execute whole snippet,but not able to setup the callback for calling specific functions by pressing specific buttons.Please note that it`s not an HDA,it`s working fine with HDAs using hou.hdaModule,but I want to call these functions on a node.Posted Images should give you a better Idea of my issue.

I have also attached the hip file
Edited by MarXindia - Sept. 2, 2022 09:25:17

Attachments:
Python Printdef.jpg (53.3 KB)
callback.jpg (31.4 KB)
pythonCallback-02.hipnc (89.2 KB)

User Avatar
Member
2625 posts
Joined: June 2008
Offline
Try specifying the function after the eval, basically running another line of code within a single click.
exec(kwargs['node'].parm('code').eval());printB()
Edited by Enivob - Sept. 2, 2022 10:58:38
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
34 posts
Joined: Sept. 2013
Offline
Enivob
Try specifying the function after the eval, basically running another line of code within a single click.
exec(kwargs['node'].parm('code').eval());printB()

Yay it works .I did find a workaround though, that looks like below,

exec('{}\nB()'.format(kwargs.parm,('code').eval()))


your solution seems pretty straight forward and convenient,Thankyou Enivob
User Avatar
Member
8 posts
Joined: Aug. 2018
Offline
Duplicate callback outputs
In the callback for output(s): layout.children Output 0 (layout.children) is already in use. Any given output can only have one callback that sets it. To resolve this situation, try combining these into one callback function, distinguishing the trigger by using dash.callback_context if necessary.
  • Quick Links