How to set Height and Width Label in tkinter
Height: It Is Used To Set Vertical Dimension.
Width: Width of The Labels in Character. If this option is not set the label will be sized to fits its content.
Example:
from tkinter import *
my_window = Tk()
my_window.title("Width and Height")
my_window.config(bg="#B4EEB4")
my_window.geometry("800x400+450+86")
my_window.geometry("800x400+450+86")
lbl1 = Label(my_window, text="I AM W=15 H=2", font=("Helvetica", 25, "bold"),
width=15, height=2) # Set Width and Height
lbl2= Label(my_window, text="I AM W=20 H=", font=("Vrinda", 30, "bold"),
bg="red",width=20, height=5) # Set Width and Heght
lbl1.pack(pady=20)
lbl2.pack(pady=10)
my_window.mainloop()
Post a Comment