1from tkinter import *
2master = Tk()
3def close_window():
4 exit()
5button = Button(master, text = 'Click me', command = close_window)
6button.pack()
7mainloop()
8
1import tkinter as tk
2
3
4def write_slogan():
5 print("Tkinter is easy to use!")
6
7root = tk.Tk()
8frame = tk.Frame(root)
9frame.pack()
10
11button = tk.Button(frame,
12 text="QUIT",
13 fg="red",
14 command=quit)
15button.pack(side=tk.LEFT)
16slogan = tk.Button(frame,
17 text="Hello",
18 command=write_slogan)
19slogan.pack(side=tk.LEFT)
20
21root.mainloop()
22