python - 几秒钟后如何删除框架及其标签?
问题描述
我正在制作一个小程序。我制作了一个框架和一个标签,其中包含一些在单击按钮后出现的文本。没关系。现在我想制作一个按钮,上面写着“后退”或“关闭”之类的东西,它关闭了那个框架和它的标签。
我要关闭的内容:
![图片]:https ://imgur.com/a/sO6rYJs
如何照顾我关闭那个框架和它的标签:
![图片]:https ://imgur.com/a/GVVny33
我尝试了一些代码,例如: frame.after(2000, lambda: frame.destroy()) 但它不起作用。我尝试了更多,但又一次..它不起作用。
def inceput():
global windows3
windows3 = Tk()
windows3.title("EasyQuizy v1.0")
windows3.geometry("600x600+600+200")
windows3.resizable(False, False)
windows3.configure(bg="#472025")
headerFrame = Frame(windows3, width=("100"), height=("0")).pack(side=TOP)
frameLeft = Frame(windows3, width="100", height="600", bg="#7b8781").place(x=0, y=0)
frameRight = Frame(windows3, width="100", height="600", bg="#7b8781").place(x=500, y=0)
header = Label(headerFrame, width=("100"), height=("3"), bg="#9d7448", fg="#d9ab33", borderwidth=1, relief="solid",
font="Helvetica 14 bold italic", text=("Bine ai venit, " + str(numeUtilizator.get()) + '!')).pack()
butonRights = Button(frameLeft, width=("9"), height=("2"), text="Drepturi de \nautor", bg="#6ab891", fg="#131313",
font="arial 8 bold", borderwidth=4, relief="raised", command = drepturi_autor)
butonRights.place(x=7, y=100)
butonInfo = Button(frameLeft, width=("9"), height=("2"), text="Imbunatatiri", bg="#6ab891", fg="#131313",
font="arial 8 bold", borderwidth=4, relief="raised")
butonInfo.place(x=7, y=180)
windows3.mainloop()
def drepturi_autor():
global frame
frame = Frame(windows3, highlightbackground="black", highlightcolor="black", highlightthickness=2, width=(390), height=(150), bg="#afd5c1").place(x=105, y=90)
label1 = Label(frame,text="EasyQuizy este o aplicatie\ncreata de mine pentru tine.", bg="#82ac96", fg="#f2f2f2", font="arial 14 bold italic").place(x=152, y=102)
frame.after(2000, frame.destroy)
解决方案
试试看
from tkinter import *
windows3 = Tk()
windows3.title("EasyQuizy v1.0")
windows3.geometry("600x600+600+200")
windows3.resizable(False, False)
windows3.configure(bg="#472025")
def drepturi_autor():
frame = Frame(windows3, highlightbackground="black", highlightcolor="black", highlightthickness=2, width=(390), height=(150), bg="#afd5c1")
frame.pack()
label1 = Label(frame,text="EasyQuizy este o aplicatie\ncreata de mine pentru tine.", bg="#82ac96", fg="#f2f2f2", font="arial 14 bold italic").place(x=100, y=52)
frame.after(2000, frame.destroy)
headerFrame = Frame(windows3, width=("100"), height=("0")).pack(side=TOP)
frameLeft = Frame(windows3, width="100", height="600", bg="#7b8781").place(x=0, y=0)
frameRight = Frame(windows3, width="100", height="600", bg="#7b8781").place(x=500, y=0)
header = Label(headerFrame, width=("100"), height=("3"), bg="#9d7448", fg="#d9ab33", borderwidth=1, relief="solid",
font="Helvetica 14 bold italic", text=('Bine ai venit!')).pack()
butonRights = Button(frameLeft, width=("9"), height=("2"), text="Drepturi de \nautor", bg="#6ab891", fg="#131313",
font="arial 8 bold", borderwidth=4, relief="raised", command = drepturi_autor)
butonRights.place(x=7, y=100)
windows3.mainloop()
推荐阅读
- ruby-on-rails - 如何为 Rails 中的模型属性创建迁移
- r - R ValueError:检查输入时出错:预期 simple_rnn_input 有 3 个维度,但得到了形状为 (1661, 3) 的数组
- javascript - JavaScript - 如何使多个 div 可在网站上拖动和移动
- java - SPNEGO 身份验证可从自定义 Java 客户端运行,但不能从 Web 浏览器运行
- python - SyntaxError: 错误的输入 ('def')
- javascript - 尝试使用 Python/Javascript/cURL 通过 API 下载 >3GB 文件
- java - 以编程方式在 TextView 中设置文本的正确方法
- r - 使用R中的正则表达式(grepl函数)从数据中的列中提取多个所需模式的正确方法是什么
- python - 获取命名元组中具有最小值的python字典项
- php - 如何使用 PHP 提取多部分 zip 文件?