-1
I am making a form by Tkinter and wanted to know how I can save his information if the user closes the application by red X page, so that after he enters again do not need to repeat everything he has already written. But he only wanted him to save in case he closes.
from tkinter import ttk
import tkinter
class jogo:
def __init__(self,root):
self.Formulario()
def Formulario (self):
self.formulario = ttk.Frame(root)
self.formulario.pack()
v= tkinter.IntVar()
ttk.Checkbutton(self.formulario
,text = "check1"
,variable = v
).pack()
lbl_entry = ttk.Label(self.formulario, text = "nome:")
lbl_entry.pack()
entry = ttk.Entry(self.formulario)
entry.pack()
lbl_entry2 = ttk.Label(self.formulario, text = "cidade:")
lbl_entry2.pack()
entry2 = ttk.Entry(self.formulario)
entry2.pack()
bt= ttk.Button(self.formulario,text = "savar", command = lambda : self.Save(entry.get(),entry2.get()))
bt.pack()
def Save(self,a,b):
print(a)
print(b)
root = tkinter.Tk()
jogo(root)
root.mainloop()