1import tkinter as tk
2class Application(tk.Frame):
3 def __init__(self, master=None):
4 super().__init__(master)
5 self.master = master
6 self.pack()
7 self.create_widgets()
8 def create_widgets(self):
9 self.w3=tk.Entry(self.master)
10 self.w3.pack(side='top')
11 self.quit = tk.Button(self.master, text='quit', command=self.master.destroy).pack()
12 self.test = tk.Button(self.master, text='print', command=self.get_text).pack()
13 def get_text(self):
14 print(self.w3.get())
15root = tk.Tk()
16app = Application(master=root)
17app.mainloop()