1from tkinter import *
2
3root = Tk()
4root.geometry("500x500")
5root.title("My App")
6root.config(bg="#ff0000")
7
8def printhi(*args):
9 print("Hi!")
10
11btn = Button(root, text="Click to print hi", command=printhi)
12btn.place(x=200, y=200)
13
14root.mainloop()
1Installing Tkinter in Windows
2Tkinter comes with the Python installer. We just need to install Python from www.python.org, and it comes along with the Python. We don't need to install it separately. Click on the checkbox of tcl/tk and IDE.