Python Callback issue

   3627   3   2
User Avatar
Member
34 posts
Joined: 9月 2013
オフライン
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 - 2022年9月2日 09:25:17

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

User Avatar
Member
2658 posts
Joined: 6月 2008
オフライン
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 - 2022年9月2日 10:58:38
Using Houdini Indie 20.5
Windows 11 64GB Ryzen 16 core.
nVidia 3060RTX 12BG RAM.
User Avatar
Member
34 posts
Joined: 9月 2013
オフライン
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: 8月 2018
オフライン
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