I've managed to get a Checkbox in the Paramater Interface (via Type Properties) to call a PythonModule script like this from the callback (in Python mode)…
kwargs.hdaModule().wholeNumbers()
and this in the “Script” tab/file (for PythonModule)…
def wholeNumbers():
print “wholeNumbers”, hou.ch(“whole”)
I would like to change the type of the accompanying ‘float’ slider to ‘integer’ depending on the toggle so it doesn't show decimals while ‘whole’.
Alternately is it possible to override the float to be whole numbers while changing it without a possible recursive loop? Anything like an increment value for floats even?
Anyway I've also made this modification so far. Is this the best way to get the node reference into there?
def wholeNumbers(kwargs):
print “wholeNumbers”, hou.ch(“whole”)
node = kwargs
print node.name()
and from the Script callback
kwargs.hdaModule().wholeNumbers(kwargs)
Note: the hou.phm() route is not recommended in this situation.
But more importantly how to access other neighbouring parameters?
Still looking for the way to set it from there. I wished for something like “@parm = changes” here
doing this…
print node
or
print lvar('number')
complain with
TypeError: ‘ObjNode’ object has no attribute ‘__getitem__’
and
NameError: global name ‘lvar’ is not defined
respectively. Only hou.ch(“number”) gets the value but I can't figure out how to write to it?!
hou.ch(“number”) = newnumber
SyntaxError: (“can't assign to function call”, ('opdefObject/TestPI?PythonModule', 19, None, None))
and so only one argument would follow as the next error trying to pass in new-value to the function.
Modifying Parameter Interface from Python Script callback
7089 3 1- GottaGetmedat
- Member
- 68 posts
- Joined: May 2013
- Offline
- GottaGetmedat
- Member
- 68 posts
- Joined: May 2013
- Offline
- GottaGetmedat
- Member
- 68 posts
- Joined: May 2013
- Offline
okay so now I've done this…
node = kwargs
np = node.parm('number')
np.set(wholeNumber)
and that lets me ‘set’ and eval sibling parameters in a python Script callback from the Parameter Interface
Remaining still is the question of adjusting the Type from float to integer, but without the worry of recursion I can set it whole after adjustment, it's just not as nice GUI-wise.
node = kwargs
np = node.parm('number')
np.set(wholeNumber)
and that lets me ‘set’ and eval sibling parameters in a python Script callback from the Parameter Interface
Remaining still is the question of adjusting the Type from float to integer, but without the worry of recursion I can set it whole after adjustment, it's just not as nice GUI-wise.
- GottaGetmedat
- Member
- 68 posts
- Joined: May 2013
- Offline
As a side note I just wanted to add that I've gotten a Parameter Interface TAB to hide and show based on a checkbox in the previous tab via…
def toggleTab(kwargs, tabname):
ovr = hou.ch(“override”)
node = kwargs
tg = node.parmTemplateGroup()
tg.hideFolder(tabname, not ovr)
node.setParmTemplateGroup(tg)
I was looking and looking for everything to do with folders through hou.Node and hou.Parm until I finally discovered much about parmTemplateGroup etc., which is the key to that. They are called parmTemplates not Folder even if they have a parameter type of Folder. At least to solve that problem.
Also working now. I'm sure I'll review this later but hope it helps someone else.
Right forgot to mention because I could not get “Tab Hide When” to work
(latest version).
I put { ch('showtab') == 1 } and every other thing that error-ed or didn't but it would not do what the code above does. In a painful and cryptic way in comparison to what seems a good idea if it actually worked as cryptic as that way is too (I would think a python expression option should exist there.)
Anyway to shed light on what gives there would be appreciated thanks.
def toggleTab(kwargs, tabname):
ovr = hou.ch(“override”)
node = kwargs
tg = node.parmTemplateGroup()
tg.hideFolder(tabname, not ovr)
node.setParmTemplateGroup(tg)
I was looking and looking for everything to do with folders through hou.Node and hou.Parm until I finally discovered much about parmTemplateGroup etc., which is the key to that. They are called parmTemplates not Folder even if they have a parameter type of Folder. At least to solve that problem.
Also working now. I'm sure I'll review this later but hope it helps someone else.
Right forgot to mention because I could not get “Tab Hide When” to work
(latest version).
I put { ch('showtab') == 1 } and every other thing that error-ed or didn't but it would not do what the code above does. In a painful and cryptic way in comparison to what seems a good idea if it actually worked as cryptic as that way is too (I would think a python expression option should exist there.)
Anyway to shed light on what gives there would be appreciated thanks.
-
- Quick Links