Is it possible to pass a variable to the Region command?

Asked by Mark McGuinn

Hi,

 I am trying to dynamically create regions on the screen at different locations and want to pass the Region() command a variable containing the co-ordinates of the new region.

base_loc = str("("+x_cord_s+","+y_cord_s+","+w_const_s+","+h_const_s+")")
reg2 = Region(base_loc)

 However when I do that it returns an error:

[error] script [ build_index ] stopped with error in line 105
[error] TypeError ( org.python.proxies.sikuli.Region$Region$3(): 1st arg can't be coerced to boolean, java.awt.Rectangle, org.sikuli.script.Region )
[error] --- Traceback --- error source first
line: module ( function ) statement
105: main ( <module> ) reg2 = Region(base_loc)
[error] --- Traceback --- end --------------

If I enter the exact same coordinates manually it works. I've tried passing a string variable and an integer variable neither worked. My question is can this be done and if it can How?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Mark McGuinn
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

simply so:

reg2 = Region(x_cord_s, y_cord_s, w_const_s, h_const_s)

supposing that
x_cord_s ...

have been set before to the needed integer values, like

x_cord_s = reg1.x + offset

where offset is again some integer value or variable

Revision history for this message
Mark McGuinn (mmcguinn) said :
#2

Many thanks for ending my frustration on this one! Just for completeness incase anyone is looking at this later the x_cord_s has to be an integer otherwise you'll trigger the coercion error.