How to Change the popup title from sikuli to Something?

Asked by Joe Harris

Title says the all, Can we change the title of sikuli popup from Sikuli to something else?
Also Can we change the buttons? like instead of okay to Enter? or in the input command can we change the Ok and cancel button? Please help to solve my problm

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Joe Harris (b5360657) said :
#1

Update: Can use the input from user input into the popup? Like.

Seconds = input("How many seconds you want me to wait?")
print("waiting for Seconds ")

Revision history for this message
RaiMan (raimund-hocke) said :
#2

--- change popup title/buttons
Not a feature currently.

--- use the user input from input()
input() returns as a string what the user has input:

answer = input("How many seconds you want me to wait?\nType a valid number only!")
print "waiting for %s seconds"%(answer)
sec = int(answer) # would work, if answer contains a valid integer number
# otherwise script will stop

to make it robust:

while True:
try:
    sec = int(input("How many seconds you want me to wait?\nType a valid number only!"))
    break
except:
    pass # will continue looping
print "waiting for %s seconds"%(answer)

Revision history for this message
Joe Harris (b5360657) said :
#3

while True:
try:
    sec = int(input("How many seconds you want me to wait?\nType a valid number only!"))
    break
except:
    pass # will continue looping
print "waiting for %s seconds"%(answer)

--------
It didn't work as the answer was not defined, it should have been sec.
If the user doesn't enter a valid value, can it popup("Please enter integers only")
Or something?

Also i would like to ask, Can we use the value of input to some string then use Myhandler?

Password = Input("Please enter your password")
if password = abc
    click(something)
else:
    break

Revision history for this message
RaiMan (raimund-hocke) said :
#4

You can do, whatever you like, as long as it is possible ;-) (says the philosopher inside myself ;-)

--- it didn't work as the answer was not defined, it should have been sec.
Sorry for the mistake ;-) or should I say, you passe the test?

--- If the user doesn't enter a valid value, can it popup("Please enter integers only")

while True:
try:
    sec = int(input("How many seconds you want me to wait?\nType a valid number only!"))
    break
except:
    popup("Please enter integers only") # after user clicks ok, will continue looping
print "waiting for %d seconds"%(sec)

--- Can we use the value of input to some string then use Myhandler?
abc = "correct password"
password = input("Please enter your password")
if password == abc:
    click(something)
else:
    exit() # would end the script here

break is only allowed to end while/for loops.

Revision history for this message
Joe Harris (b5360657) said :
#5

Hahahha, I like the thought (-;

yay! I passed :D

Tried both of them, they're not working

while True:
 try:
     sec = int(input("How many seconds you want me to wait?\nType a valid number only!"))
     break
except:
    popup("Please enter integers only") # after user clicks ok, will continue looping
print "waiting for %d seconds"%(sec)

This is giving me some Indent error, though i have indented.

Second one,
abc = "correct password"
password = input("Please enter your password")
if password == abc:
    popup("correct password")
elif popup("wrong pass")
else:
    exit() # would end the script here
always gives me "[info] Exited with code 0 "
it always end, regardless of correct or wrong password
Thanks for the feedback :)

Revision history for this message
Best RaiMan (raimund-hocke) said :
#6

-- indentation errors:
take care, that the indentations are equally produced (recommendation: use tab/shift-tab to indent/dedent one level - supported in the IDE edit menu). Never enter the indentation with blanks - this gets a mess very fast.

-- if/elif/else

abc = "correct password"
password = input("Please enter your password")
if password == abc:
    popup("correct password")
else:
    popup("wrong pass")
    exit() # would end the script here

elif is only of value if you have many different cases to test:

if case1:
   pass
elif case2:
   pass
elif case3:
   pass
else:
   pass

if none of the if/elif return true, the else tree is processed.

Revision history for this message
Joe Harris (b5360657) said :
#7

Weird it always tells me Wrong pass. I'm pretty sure, I have typed the correct password. What the heck, Sikuli don't play with me. :p Please tell what might be the problem?

Revision history for this message
RaiMan (raimund-hocke) said :
#8

pls paste your script here

Revision history for this message
Joe Harris (b5360657) said :
#9

The same script you wrote.. i.e
abc = "correct password"
password = input("Please enter your password")
if password == abc:
    popup("correct password")
else:
    popup("wrong pass")
    exit() # would end the script here

no errors, just "[info] Exited with code 0" this.

Revision history for this message
RaiMan (raimund-hocke) said :
#10

only to be sure:
to get the popup "correct password", you have to type in "correct password" (without the apostrophes) at the input prompt.

password contains the text you have entered and it is compared to the text content of abc.

Revision history for this message
Joe Harris (b5360657) said :
#11

Okay, Thank you I was trying with abc. I'm sorry. Thank you RaiMan, you made another man happy today :)))

Revision history for this message
Joe Harris (b5360657) said :
#12

Thanks RaiMan, that solved my question.