New question #280949 on Sikuli:
https://answers.launchpad.net/sikuli/+question/280949

I am using the region.text() function to get a string from a region that is 
constantly changing (a floating point number that changes every half second).

Once the text is captured, I convert the text into a floating point number and 
do analysis on this number:

for example:

str = myRegion.text()
myNum = float(str)

myNum = myNum + 5.0
print myNum

In most cases the capture works fine and I'm able to print out correctly.  But 
in some iterations the text capture fails and the program crashes on the "myNum 
= float(str)" line because its trying to convert an invalid string capture into 
a float.

I know the text() function is still in development but, does anyone have an 
idea of how I can do a check first to make sure the string has a valid float 
format before I do the conversion to a float value?

I've tried playing around with the str.isdigit(), str.isalpha(), str.isspace() 
functions on the captured string first but they all crash when they try to 
check the invalid string.  

Thanks, Ken



-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to