CinnamonMetal Posted October 5, 2017 Share Posted October 5, 2017 I'm hung on a problem, with python. hou.ui.readInput() produces a tuple; I have a while loop but I can't get the index item of the tuple which is the "OK" button of the class not to disappear if the string is empty ? In other words, if the user clicks "OK" the dialog should not disappear. Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted October 5, 2017 Share Posted October 5, 2017 Not clear what are you trying to do. Post your code example here so I could help. Quote Link to comment Share on other sites More sharing options...
CinnamonMetal Posted October 5, 2017 Author Share Posted October 5, 2017 nodeName = hou.ui.readInput("what do you want",buttons=('OK',"Cancel"),default_choice=0,title="Name the sphere",close_choice=1) if nodeName[0] == 0 and nodeName[1] !="": intro = hou.node("/obj").createNode("geo","geometryA") superGeo = intro.createNode("sphere",nodeName[1]) superGeo.setPosition([2.3,4.5]) superGeo.setParms({"radx":2.3,"radz":4.2,"type":"bezier","rows":54}) fileNode = hou.node("/obj/geometryA/file1") fileNode.destroy() superGeo.setRenderFlag(True) else: while not nodeName[0] == nodeName[0]: hou.ui.displayMessage("You must supply a valid node name") break Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted October 6, 2017 Share Posted October 6, 2017 while True: btn, nodeName = hou.ui.readInput("what do you want",buttons=('OK',"Cancel"),default_choice=0,title="Name the sphere",close_choice=1) if btn == 0 and nodeName: intro = hou.node("/obj").createNode("geo","geometryA") superGeo = intro.createNode("sphere",nodeName) superGeo.setPosition([2.3,4.5]) superGeo.setParms({"radx":2.3,"radz":4.2,"type":"bezier","rows":54}) fileNode = intro.node("file1") fileNode.destroy() superGeo.setRenderFlag(True) break Quote Link to comment Share on other sites More sharing options...
CinnamonMetal Posted October 6, 2017 Author Share Posted October 6, 2017 I one more question. How do I get the "OK" button to loop repeatedly if strictly the "OK" button is pressed ? I'm hacking away at this and I hope, that I solve this before hopefully your reply. Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted October 7, 2017 Share Posted October 7, 2017 (edited) 19 hours ago, CinnamonMetal said: I one more question. How do I get the "OK" button to loop repeatedly if strictly the "OK" button is pressed ? I'm hacking away at this and I hope, that I solve this before hopefully your reply. Do not use break keyword inside the if statement and you'll get an infinite loop. Edited October 7, 2017 by Stalkerx777 Quote Link to comment Share on other sites More sharing options...
CinnamonMetal Posted October 7, 2017 Author Share Posted October 7, 2017 If I make an infinite loop when the user enters some text instead of the rest of the script executing; the else statement is executed and the variable = nodeName does an infinite loop completely ignoring to execute the script ? I want the infinite loop strictly for the OK button, although not for the CANCEL button. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.