sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #03802
Re: [Question #142149]: [Python] How to save/reload regions using a file
Question #142149 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/142149
Summary changed to:
[Python] How to save/reload regions using a file
Description changed to:
****** solution with Python marshal
See comment #7
---------------------------------------------------
Hello I'm running into something I can't figure out. This might be a
python question than sikuli but since sikuli functions is involve I
should ask here. I trying to write several region to a file called
region.txt
3 Region Variables:
r1=Region(252,120,150,25)
r2=Region(252,140,150,25)
r3=Region(252,160,150,25)
#Save Function call by swing button
def save(event):
filename="C://region.txt"
regionfile=open(filename,"w")
regionfile.write("r1="+str(r1)+"\n"
regionfile.write("r2="+str(r2)+"\n"
regionfile.write("r3="+str(r3)+"\n"
regionfile.close()
I open the file and it produce these:
r1=Region[252,120 150x25]@Screen(0) E:Y, T:3.0
r2=Region[252,140 150x25]@Screen(0) E:Y, T:3.0
r3=Region[252,160 150x25]@Screen(0) E:Y, T:3.0
instead of these:
r1=Region(252,120,150,25)
r2=Region(252,140,150,25)
r3=Region(252,160,150,25)
I tried using pickle dump but it cannot coarse to int and obviously converting it to strings won't work either. Any suggestion? My only other option might have to create a separate function to open the file and delete or change those unwanted extra characters. I do need to read from this file too just fyi
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.