Python 3 Tkinter Hide or Make Label Widget Invisible on Button Click Event GUI Desktop App Full Project For Beginners

 

 

main.py

 

 

#Import the required libraries
from tkinter import *

#Create an instance of tkinter frame
win= Tk()

#Set the geometry of frame
win.geometry("600x250")

#Set the resizable property False
win.resizable(False, False)

#Make the widgets Invisible
def make_invisible(widget):
   widget.pack_forget()

#Create a label for the window or frame
label=Label(win, text="Hello World!", font=('Helvetica bold',20),
anchor="center")
label.pack(pady=20)

#Create a button to make the widgets invisible
btn=Button(win, text="Click", font= ('Helvetica bold', 10), command=lambda:
make_invisible(label))
btn.pack(pady=20)

win.mainloop()

Leave a Reply