← Back to team overview

sikuli-driver team mailing list archive

[Question #142149]: Write Sikuli Var to file

 

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

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.