To add padding to the Tkinter label, you would need to make use of padx and pady properties.
padx: Will add padding to the label vertically in the left and right.
pady: Will add padding to the label horizontally at the top and bottom.
Example:from tkinter import *
window = Tk()
my_text_label = Label(window, text='This is some text', width=50, height=20, bg='yellow')
my_text_label.pack(padx=10, pady=10)
window.mainloop()
Example Output:
⛏️ Unlike setting weight and height - padding properties are associated with the pack method.
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!