This question already has an answer here:
- Why does closing a tkinter child window with `frame.quit` exit my application? [duplicate] 1 answer
I would like the second 'Enter' button to allow the user to quit from this window. What is the command? I believe self.quit quits everything but the command I've used doesn't work.
import tkinter as tk
class Enter_Name_Window(tk.Toplevel):
'''A simple instruction window'''
def __init__(self, parent):
tk.Toplevel.__init__(self, parent)
self.text = tk.Label(self, width=40, height=2, text= "Please enter your name and class." )
self.text.pack(side="top", fill="both", expand=True)
enter_name = Entry(self)
enter_name.pack()
enter_name.focus_set()
def callback():
self.display_name = tk.Label(self, width=40, height=2, text = "Now please enter your tutor group.")
self.display_name.pack(side="top", fill="both", expand=True)
tutor = Entry(self)
tutor.pack()
tutor.focus_set()
Enter_0.config(state="disabled")
Enter_0_2 = Button(self, text="Enter", width=10, command=Enter_Name_Window.quit)
Enter_0_2.pack()
Enter_0 = Button(self, text="Enter", width=10, command=callback)
Enter_0.pack()