Jump to content

button strip get selected button values

Recommended Posts

Hi guys,

I've got a button strip with multi selection. How can I get which items are selected in python? Evaluating the parameter adds them all up into a single number. 


Any help would be appreciated.


Share this post

Link to post
Share on other sites

Hi Dominic,
it is called bitfield, here is the description how to use it:


Another example: I have a Button strip, the Callback script I have:
hou.phm().strip_to_tokens(kwargs['parm'], kwargs['node'])

Then in scripts, PythonModule:

def strip_to_tokens(parm, node):
    bitfield = parm.eval()
    tokens = parm.parmTemplate().menuItems()
    pitch_tuple = [token for n, token in enumerate(tokens) if bitfield & (1 << n)]
    pitch_tuple_string = ' '.join(  (map( str , pitch_tuple ) )  )

  • Thanks 1

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now