Also demonstrate changing the text of the widgets label dynamically.
Demonstrating Tkinter pack and pack_forget
from Tkinter import *
root = Tk()
button = Button(text="Push me", command=toggle)
button.pack()
label = Label(text="Hello")
label.pack()
def toggle():
if label.winfo_ismapped():
button['text']='unmap'
label.pack_forget()
else:
button['text']='map'
label.pack()
root.wait_window()
TrustyTony 888 pyMod Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.