How To Use Justify in Label 

Justify: It Contains New Line Characters. How Each Line is Positioned Horizontally. The Valid Value of Justify is LEFT, RIGHT and CENTER. Default Value is CENTER.

Example: 


from tkinter import *
my_window = Tk()
my_window.title("Anchor And Justify Example")
my_window.config(bg="#B4EEB4")
my_window.geometry("800x400+450+86")
my_window.state("zoomed")


lbl1 = Label(my_window, text="This is Justify Left \n Hasan", font=("Helvetica",15
                   "bold"), width=35, height=9, anchor=CENTER, justify=LEFT)


lbl2= Label(my_window, text="This is Justify Right \n Hasan", font=("Vrinda", 15
               "bold"),bg="#FFD700",width=35, height=9, anchor=CENTER, justify=RIGHT)


lbl3= Label(my_window, text="This is Justify Center \n Hasan", font=("Vrinda", 15,   
            "bold"),  bg="#969696",width=35, height=9, anchor=CENTER, justify=CENTER)


lbl1.pack(pady=5)
lbl2.pack(pady=10)
lbl3.pack(pady=10)
my_window.mainloop()

 

Write Down Code Your Code Editor. To show Your Output. If Use Pycharm Press Shift+F10 and Show Your Output.



Lets enjoy.............


Post a Comment

أحدث أقدم