按钮隐藏/显示

时间:2021-03-07 15:46:29

标签: python tkinter button canvas

我目前正在尝试创建一个可以使用定义 (def) 隐藏或显示的按钮。

root.Tk()
c = Canvas(root, wodth=1600, Height=100, bg='black')
root.attributes('-fullscreen', True)
c.pack
b = Button(c, text='I want to by unvisiblie')
b.place(x=210, y=88)

root.after(1)

你能帮我吗?我该怎么做(请不要任何自我命令)? 谢谢

1 个答案:

答案 0 :(得分:0)

所以... 您可以使用“place_forget”隐藏任何小部件..

所以这是可以帮助你的!

from tkinter import *
root = Tk()
a_button = Button(c, text='I want to by unvisiblie', command = lambda:b.place_forget())# I think the text should be "I want to be invisible!"
a_button.place(x=210, y=88)
root.mainloop()

我希望你想要这个答案