【问题标题】:Button hide/show按钮隐藏/显示
【发布时间】:2021-06-05 15:44:46
【问题描述】:

我目前正在尝试创建一个可以通过定义 (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)

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

【问题讨论】:

  • 查看this 了解如何隐藏按钮和this 了解如何使元素再次可见。
  • 我建议你先上tkinter的教程。
  • 一旦你点击按钮,按钮就会隐藏,你打算如何再次将其调出。

标签: python tkinter button canvas


【解决方案1】:

所以... 您可以使用“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()

我希望你想要这个答案

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-27
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多