hou.ui.readInput() Only output zero at the first tuple

   Views 1210   Replies 4   Subscribers 0
User Avatar
Member
5 posts
Joined: Oct. 2021
Offline
No matter which button I press, It always output zero at the first tuple...

input = hou.ui.readInput("Test Button Output", default_choice=0, close_choice=-1)
print(input)
if input[0] == -1:
    print("exit")
if input[0] == 0:
    print("enter")
    
# It always output 0 on input[0] but it should be -1 if I press exit button or esc
Edited by artchapter - May 20, 2022 06:27:28

Attachments:
Sample_readinput.hip (86.5 KB)

User Avatar
Member
16 posts
Joined: March 2024
Offline
hello,
i'm experiencing the same issue actually on Houdini 19
User Avatar
Member
318 posts
Joined: Jan. 2013
Offline
As it follows from the documentation: The integer is the index of the pressed button.

This is necessary for those cases when you have more than one button by default the button argument is 'OK', if you make a tuple containing more than one button it will return the corresponding index.
User Avatar
Member
16 posts
Joined: March 2024
Offline
yeah i had to replace our solution by a pyside dialog that support close event
User Avatar
Member
16 posts
Joined: March 2024
Offline
Hi,
It actually works using a Cancel Button and close_choice=1

result,comment = hou.ui.readInput("Add your entry:", title="String input", initial_contents="", buttons=("OK", "Cancel"),close_choice=1)
if result == 1 : return
else : return comment
Edited by sebd3dvfx - May 6, 2024 09:42:30
  • Quick Links