Jump to content
Sign in to follow this  
probiner

Easiest way to present a simple dialog to the user when running a shelf script?

Recommended Posts

What't the easiest way to present a user with a set of options when running a python script from the shelf?
Is there by chance a way to use the Parameter Interface Editor, save that, call it from the script commit, and use the information from it?
tBcCwfd.png

I've used hou.ui.readInput for simple string inputs, but I don't want to make that pop one after the other for several options.

Thanks

Share this post


Link to post
Share on other sites
Posted (edited)

" Is there by chance a way to use the Parameter Interface Editor, save that, call it from the script commit, and use the information from it? "

that would be nice but i dont think its doable

PyQt is the best way I know of creating custom UIs

Edited by garf

Share this post


Link to post
Share on other sites

If you decide to go with PyQt UI tutorial might be helpful for the beginning.

Share this post


Link to post
Share on other sites
Posted (edited)

Thanks to @Stalkerx777 for his library: https://bitbucket.org/alexxbb/huilib/overview

Really fits my needs here of having some simple options for something that is just to run once.

z2VxYzt.png

@garf Indeed I'll go down that path for heavy lifting stuff. But atm that would be a rabbit hole for me.
@kiryha Thanks for producing that! Sounds like it will be verbose for evolved things (maybe even more than what is being executed) and probably a good opportunity to get in to code generators.

 

Edited by probiner
  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)

So where do you place huilib.py so the include from the shelf tool can find it?

Edited by Atom

Share this post


Link to post
Share on other sites
Posted (edited)

You can put it in app folder : Houdini 17.xx/python27/lib
Probably not the best location, but at least Houdini finds it.
On the other side, I can't get it to work.
I included a small print test in the library to be sure.
And I try with the two sample but nothing happen !

Edited by flcc

Share this post


Link to post
Share on other sites
Posted (edited)

Ah, got it.

Get rid of that condition, at the bottom of the script and it does launch.

ui = TestDialog(name = 'test', title = 'Test UI')
ui.show()

 

Untitled-1.jpg

Edited by Atom

Share this post


Link to post
Share on other sites
Posted (edited)

Ah yes, thanks

Trying in the source Windows and it's the same.
Does this mean that this condition should not be used in houdini ?
(sorry, pretty new with python in houdini)
 

Edited by flcc

Share this post


Link to post
Share on other sites
Posted (edited)

@Atom I've been looking at Python in Houdini only recently, so I look forward to get more people's insight.

Put it in any of the locations corresponding to $HOME, $HSITE, $HIP, $JOB inside a structure like {loocation}/{houdiniversion}/python2.7libs/
For example I have $HSITE at F:/HOUDINI/HSITE/ so I put the huilib.py  in F:/HOUDINI/HSITE/houdini17.0/python2.7libs/
After this import huilib in the shelf tool Script field will be able to find it.

As for running the examples, here I'm not so sure about the correct method, but what I've been doing is putting my scripts in a subfolder ../python2.7libs/PRB_HOM/  which contains an empty __init__.py  and then call those scripts from the shelf with import.
For example, I've put in said folder the example shipped with huilib, all_gadgets.py, while changing the script bottom part from:
 

if __name__ == '__main__':
    ui = TestDialog(name = 'test', title = 'Test UI')
    ui.show()

into

def main():
    ui = TestDialog(name = 'test', title = 'Test UI')
    ui.show()


if __name__ == '__main__':
    main()

And then in the shelf tool Script field I can do:

from PRB_HOM import all_gadgets as tool
reload(tool)
tool.main()

arWTu7z.gif

And this way it gets picked up. This is how I'm running my shelf tools in general, so I can store .py files in a repo and use an external editor and not have the scripts stored in the .shelf file.

But I'm curious to know if this is "the proper" way to do it @Stalkerx777 or anyone! :)

It would still be nice if we could work in the Parameter Editor and store that into a .ui file.

Cheers

PS: I failed to refresh the page and notice you guys already sorted it :)

Edited by probiner
  • Like 1
  • 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
Sign in to follow this  

×