Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

python what does lable do

hey guys can anyone explain this code

from tkinter import *

def create_window():
    new_window = Tk()
    old_window.destroy()
    Label(new_window,text='hi').pack()
old_window = Tk()

Button(old_window,text="create new window!",command=create_window,).pack()

old_window.mainloop()

why he write the lable intead of just writing text= in new_window and who actually lable work
I searched for this topic on YouTube, but I did not find an answer to my question. they just writes a label without any explanation as to why he wrote it.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Label is a widget that implements a display box where you can place text or images. The text displayed by this widget can be updated at any time you want.

So this line:

Label(new_window,text='hi').pack()

Does the following: create a text saying hi in the window called new_window, then displays it by using the .pack() method

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading