uiS[cript]Py: Quick 1st Example

NOTE there seems to be a quirk where wordpress is mutating certain symbols so to use example properly for now, please copy and paste to a text editor, and replace the single quote with.. Yes, what appears to be the same single quote on your keyboard… if you run into this issue. When I have it patched, this note will no longer ne here. Thanks.

Here is a quick example to get everyone started. Its not particularly meaningful but shows basic usage. The manual is in HTML with the download and is fairly complete. If its in there and promoted to the uispy namespace, for the most part its been working. Methods have docstrings and if using the built-in houdini Py Shell, you will see them as normal in the nice little popup.

import uiScriptPy as uispy

# basic container is needed in this case a row
myrow = uispy.ColunnUiScriptContainer(‘myrow’)

# a simple float tuple
myfloat = uispy.FloatUiScriptGadget(‘myfloat’, ‘My Float’, 3)

# Top of dialog
mywin = uispy.DialogUiScriptWindow(‘mywin’, ‘My Win’)

# set the float to the row
myrow.setUiScriptGadgets((myfloat,))

# set the container to the dialog
mywin.setUiScriptGadgets((myrow,))

# create a basic interger and set range on slider
myint = uispy.IntUiScriptGadget(‘myint’, ‘My Int’)
myint.setSliderRange(-10,10)

# append slide to the row container
myrow.addUiScriptGadget(myint)

# color widget with alpha
mycolor = uispy.ColorUiScriptGadget(‘mycolor’, ‘My Color’, has_alpha=True)

# a password string field
mypassword = uispy.StringUiScriptGadget(‘password’, ‘Password’)
mypassword.setIsPassword(True)

# a lablel with a little styling
mylabel = uispy.LabelUiScriptGadget(‘mylabel’, ‘My Label’)
mylabel.setTextLook(uispy.uiScriptTextLook.underline)

# basic column container
mycol = uispy.ColunnUiScriptContainer(‘mycol’)

# add color, password, and label to column
mycol.addUiScriptGadget(mycolor)
mycol.addUiScriptGadget(mypassword)
mycol.addUiScriptGadget(mylabel)

# a collapser is uncommon but useful to conserve space
# create collapsed initally, and containing column of widgets  
mycollapser = uispy.CollapserUiScriptContainer(‘mycollapser’, ‘My Collapser’, (mycol,), collapsed=True)

# set the row and collapser to the window
mywin.setUiScriptGadgets((myrow, mycollapser))

# create the dialog from the script
d = mywin.createHouDialog()

# now we can retrieve a gadget from the dialog
#  this can be thought of similar to a parameter object
#  for the parameter pane via parmTemplates
myfloat_gadget = d.uispy_gadgetTuple(‘myfloat’)

# query the raw values
myfloat_gadget.get()

# use extended method provided to destroy dialog cleanly
d.uispy_destroy()