Tkinter Grid

  • Post category:Tkinter

In this Tkinter tutorial, you will learn how to set the Tkinter Grid.

# import Tkinter Module
import tkinter as tk

# create main window
var = tk.Tk()

# Set title
var.title("My Tkinter")

# create a label
var2 = tk.Label(var, text="This is a given label")

# pack label
var2.grid(row=0, column=0)

# create a button
var3 = tk.Button(var, text="Click Me, First button", fg="white", bg="blue")

# pack button
var3.grid(row=0, column=1)

# create an entry
var4 = tk.Entry(var)

# pack entry
var4.grid(row=1, column=1)

# start the event loop
var.mainloop()

Output:

Free resources to learn advanced skills: AiHints and CodeAllow