Every time this code is reopened the insertion cursor moves one line lower, how do I stop this?
import Tkinter,pickle
class Note(Tkinter.Tk):
def __init__(self,parent):
Tkinter.Tk.__init__(self,parent)
self.parent = parent
self.Main()
self.load_data()
self.protocol("WM_DELETE_WINDOW", self.save_data)
def Main(self):
self.s1 = Tkinter.Scrollbar(self)
self.L1 = Tkinter.Text(self,borderwidth=0,font=('Arial', 10),width=25,
height=15)
self.s1.config(command=self.L1.yview,elementborderwidth=3)
self.L1.config(yscrollcommand=self.s1.set)
self.L1.grid(column=0,row=0,sticky='EW')
self.s1.grid(column=1,row=0,sticky='NSEW')
self.L1.focus_set()
def save_data(self):
data = {'saved_data': self.L1.get('1.0', 'end')}
with file('testsave.data', 'wb') as f:
pickle.dump(data, f)
self.destroy()
def load_data(self):
try:
with file('testsave.data', 'rb') as f:
data = pickle.load(f)
self.L1.insert("end", data['saved_data'])
except IOError:
pass
if __name__ == "__main__":
app = Note(None)
app.mainloop()