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()

 

uiS[cript]Py: Announcement. uispy download available

logo_400pxw

I have decided to make available a python wrapper for Houdini’s uiscript. It has been the result of needs I have had and was largely ripped from another defunct project. It should be considered alpha. I am aware of a couple efforts to do this, however I think uispy is fairly robust and useful.

Hopefully this will also provide an exploratory opportunity to document its clean-up here on  eyevex.com bit by bit in the New year (assuming compatibility with h16 for now). At that time some examples, tutorials and explanations will be coming, until then feel free to download and poke around.

It is acknowledged, that a few things are broken or missing, some the scripts are a bit hacky, there are places for improvement, and a bit that is completely wrong, but working. This is alpha, which mean it has only been used my myself and really only on a specific setup, in my case that’s Linux 64, kubuntu. Earlier versions were tested win win7, but have not been in sometime. Its development also means it lack some safety checks and sometimes you may be allowed to use values that wont properly build the dialog. This will be an area of improvement as the module is cleaned up.

Why do this at all…. There’s a few reasons to… and a few reasons not to. As uiS[cript]py uses only standard python and built-in Houdini libs, it provides a clean and safe way to create simple dialogs beyond the basic tree, multiline and lists in HOMs hou.ui While currently pySide and pyQt provide ways to build large robust interfaces, often a simple native dialog without worrying about qt deps or learning large libs is needed, and this fills that space. For those familiar with parmameterTemples in HOM, the naming of methods and usage closely mirrors that workflow. UI Script is also used for Cpp plugs as a quick way to build interfaces, in the future this may provide an easy way to design uis visually and dump the script.

This is a more advanced topic and not all basics wont be gone over, hopefully all interested will get something from it, but in the end the inner workings will likely most interesting to Pipeline/dept/show Tds. Example usages will probably be of broader interest and for reader that just wants to get to using it.

happy CG’ing. (|;-D>