基本上我有这个应用程序:
当我按下其中一个按钮时,它下面会有一个标签。现在假设我想按下另一个按钮,如何删除以前的标签并显示新标签?
例如:如果我按下数据集 1,它将显示是,但如果我按下数据集 3,它将删除是并显示可能。
到目前为止我的代码:
def printit(number):
if number == 1:
Label(win,text="yes",fg="blue",bg="yellow",font = ("Calibri 10 bold")
).place(x=12,y=400)
if number == 2:
Label(win,text="no",fg="blue",bg="yellow",font = ("Calibri 10 bold")
).place(x=12,y=400)
if number == 3:
Label(win,text="maybe",fg="blue",bg="yellow",font = ("Calibri 10 bold")
).place(x=12,y=400)
win = Tk()
win.geometry("400x600")
win.configure(background="cyan")
win.title("Ensemble Method")
title = Label(win, text="AdaBoost", bg="gray", width="300", height="2", fg="white",
font = ("Calibri 20 bold italic underline")).pack()
canvas= Canvas(win, width= 400, height= 600, bg="cyan")
#Add a text in Canvas
canvas.create_text(200, 30, text="choose which dataset you want", fill="black",
font=('Helvetica 15 bold'))
canvas.pack()
dataset_1 = Button(win, text="dataset 1", width="12",height="1",activebackground="violet",
bg="Pink", command=lambda: printit(1),font = ("Calibri 12 ")
).place(x=20, y=200)
dataset_2 = Button(win, text="dataset 2", width="12",height="1",activebackground="violet",
bg="Pink", command=lambda: printit(2), font = ("Calibri 12 ")
).place(x=150, y=200)
dataset_3 = Button(win, text="dataset 3", width="12",height="1",activebackground="violet",
bg="Pink", command=lambda: printit(3),font = ("Calibri 12 ")
).place(x=280, y=200)
win.mainloop()