Python Program using Tkinter with the pack method


In this program, you will learn how to implement Tkinter with the pack method in Python.


from tkinter import *
parent = Tk()

Example: How to implement Tkinter with the pack method in Python

from tkinter import *

parent = Tk()
parent.title("Xiith.com")
parent.geometry("600x500")

redbutton = Button(parent, text="Red", fg="red")
redbutton.pack(side=LEFT)
greenbutton = Button(parent, text="green", fg="green")
greenbutton.pack(side=RIGHT)
bluebutton = Button(parent, text="Blue", fg="blue")
bluebutton.pack(side=TOP)
blackbutton = Button(parent, text="black", fg="black")
blackbutton.pack(side=BOTTOM)
parent.mainloop()

Output:

tkinter simple example