Jump to content

pressing a button with python.


Symbolic

Recommended Posts

Hi,

I am trying to trigger a button of an OTL with a small python script.

target=hou.pwd();

target.parm("parm").pressButton();

When I run this in the python editor... it just kills houdini.

If I put that script on a script SOP... it klicks the button, I get my result... and then in crashes.

Any ideas? Thanks.

Link to comment
Share on other sites

What exactly is your button doing? Can you post an example? I use it all the time and have no problems.

Well,

The button is on an imaginary OTL right now.

The script on the OTL is:

def runMe():
	self = hou.pwd()
	hou.ui.displayMessage("Hit me! " + str(self))  

def execute():
  runMe()

The button it self has this script:

hou.pwd().hdaModule().runMe()

Then when you click the button, you get the message.

When you try to triger it with the python script... things go terribly wrong.

?!

:(

Edited by Symbolic
Link to comment
Share on other sites

I can definitely reproduce and will submit a bug. I have an idea why it's hanging. I'll ask around.

Edit:

Bug submitted: 36185

Running the following line from the shell in the attached file causes the problem.

hou.node("/obj/gthompson_geo11").parm("parm").pressButton()

button_crash.hip

Edited by graham
Link to comment
Share on other sites

Hah! So it is a bug?! :)

Any solutions?... ideas?... I just have lots of OTLs and selecting all of them -> pressing that button... does not work. I need to have a small script going through a list of those OTLs and trigering that button :blink:

Simple.

Edited by Symbolic
Link to comment
Share on other sites

I'm pretty sure the problem is caused by the fact you are attempting to display the message window. If you remove that line and say print or something else it's fine. It looks like a thread locking problem between the shell and the UI your callback is trying to display.

A quick way around that right now would be to do something like this for each asset.

cwd = hou.pwd()
hou.setPwd(my_node)
my_node.hdaModule().runMe()
hou.setPwd(cwd)

This avoids the callback and gets around the bug in my tests. If you had your runMe function defined differently you could get around not having to set the current directory but that's not really a big deal.

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...