sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #51571
[Question #680679]: SikuliXIDE; Mojave; Robot Framework: How does one get Region objects to work in Jython functions that are passed in from Robot Framework
New question #680679 on Sikuli:
https://answers.launchpad.net/sikuli/+question/680679
I am passing captured Region objects from RFW to some Jython functions within the SikuliX IDE, but RFW will convert the object to a string. In other words Region(820,467,120,50) is now a string that gets passed to a variable in the function. Thus if I try to use that for setting regions of interest, I believe I'll have to get those numbers converted back to integers or setROI(region) will not work.
I believe that I can parse all those numbers out of the string and convert each to an integer like : X, Y, H, W so instead of using setROI(region) I'd have to use setROI(X, Y, H, W). The problem with doing this is the regions I pass into the function will have different sized integers so parsing would be a pain. Is there something easier than parsing to get the function region variable into a state that will make it work? Below is the Jython function I'm using. It all works except the part with the "region" variable. I can substitute the real Region object into it and it works fine so I know the RFW is messing it up.
# Function opens the Column Options context menu for a specified DataSets X or Y column you must already be
# in Table View or Graph and Table view and use the correct variables
# selected_view = T_VIEW, or GT_VIEW so it knows what Region to look for the overflow elipses in
# dataset = DATA_SET_1 or some other recorded image and name for a dataset
# column = COLUMN_X, or COLUMN_Y so it defines region of interest for locating correct elipses
# region = T_X_REGION, T_Y_REGION, GT_X_REGION, GT_Y_REGION to define region with elipses to click
# overflow = image object of elipses to click and open context menu
# appregion to set Region of Interest back to the full app view
def column_options_context_menu (self, selected_view, dataset, column, region, overflow, appregion):
dataset = dataset[1:-1] # parse off double quotes caused by RFW
overflow = overflow[1:-1] # parse off double quotes caused by RFW
if exists(dataset, 5):
print "Dataset found"
else:
raise ValueError("dataset doesn't appear to be visible")
if selected_view == "1":
print "Table View" # No graph visible here
if column == "1":
print "Working with X column"
setROI(region)
elif column == "2":
print "working with Y column"
setROI(region)
else:
raise ValueError("column variable 1 is incorrect")
elif selected_view == "2": # graph and table will be visible
print "Graph and Table view"
if column == "1":
print "Working with X column"
setROI(region)
elif column == "2":
print "working with Y column"
setROI(region)
else:
raise ValueError("column variable 2 is incorrect")
else:
raise ValueError("selected_view variable is incorrect")
highlight(1)
mouseMove(100, 0) # move in case Graph is there as it changes the curser to crosshair
wait(1) # time for switching cursor back to arrow once off the Graph
hover(overflow)
click(overflow)
wait(2) # give enough time for the context menu to appear
setROI(region) # reset Region of Interest back to the full app region view
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.