Jump to content

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


probiner

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

Link to comment
Share on other sites

" 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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

@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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...