【发布时间】:2023-03-31 23:19:01
【问题描述】:
一旦第二个标签的命令通过(通过按下另一个按钮),我需要前一个标签消失或销毁。我不希望小部件落后,只是被新的遮蔽,我需要它们完全消失。
from tkinter import *
root=Tk()
root.geometry('800x600+0+0')
f1=Frame(root, width=700, height=200, bg='green')
f1.pack()
f2=Frame(root, width=700, height=200, bg='yellow')
f2.pack()
def hello():
l1=Label(f2,text='Hello button pressed', fg='red').pack()
def bye():
l2=Label(f2,text='Secondly, Bye button pressed', fg='blue').pack()
b1=Button(f1, text='Hello', command=hello).pack()
b2=Button(f1, text='Bye', command=bye).pack()
【问题讨论】:
标签: python-3.x tkinter widget