I wrote the beautiful python example code below. Now how do I make it so when I exit then restart the program it remembers the last position of the scale?
import Tkinter
root = Tkinter.Tk()
root.sclX = Tkinter.Scale(root, from_=0, to=1500, orient='horizontal', resolution=1)
root.sclX.pack(ipadx=75)
root.resizable(False,False)
root.title('Scale')
root.mainloop()
Edit:
I tried the following code
import Tkinter
import cPickle
root = Tkinter.Tk()
root.sclX = Tkinter.Scale(root, from_=0, to=1500, orient='horizontal', resolution=1)
root.sclX.pack(ipadx=75)
root.resizable(False,False)
root.title('Scale')
with open('myconfig.pk', 'wb') as f:
cPickle.dump(f, root.config(), -1)
cPickle.dump(f, root.sclX.config(), -1)
root.mainloop()
But get the following error
Traceback (most recent call last):
File "<string>", line 244, in run_nodebug
File "C:\Python26\pickleexample.py", line 17, in <module>
cPickle.dump(f, root.config(), -1)
TypeError: argument must have 'write' attribute