I have tried unsuccessfully several times to get programs to remember settings after they've been destroyed. A large reason for that is because I don't have an example code to work off of. Below I have a simple program I wrote. I'd like it so that it both remembers the position of the scale, and the contents of the text widget upon restarting the program. I hate having to ask someone to write code for me, but I'm honestly stuck.
I'm using Python 2.6.5 on Windows 7, BTW.
Code:
import Tkinter
class simpleapp_tk(Tkinter.Tk):
def __init__(self,parent):
Tkinter.Tk.__init__(self,parent)
self.parent = parent
self.initialize()
def initialize(self):
self.sclX = Tkinter.Scale(self, from_=0, to=100, orient='horizontal',resolution=1,command=self.A)
self.sclX.pack(ipadx=75)
self.labelVar = Tkinter.StringVar()
self.label = Tkinter.Label(self,textvariable=self.labelVar)
self.label.pack(ipadx=75)
self.frame = Tkinter.Frame(self,relief='ridge',borderwidth=4)
self.frame.pack()
self.LVariable = Tkinter.StringVar()
self.s = Tkinter.Scrollbar(self.frame)
self.L = Tkinter.Text(self.frame,borderwidth=0,font=('Arial', 10),width=30, height=15)
self.s.config(command=self.L.yview,elementborderwidth=1)
self.L.grid(column=0,row=0,sticky='EW')
self.s.grid(column=1,row=0,sticky='NSEW')
def A(self, event):
self.labelVar.set(100 - self.sclX.get())
if __name__ == "__main__":
app = simpleapp_tk(None)
app.mainloop()