我正在编写一个小程序。单击按钮后,我制作了一个框架和一个带有一些文本的标签。没关系。现在,我想制作一个按钮,说“ back”或“ close”之类的东西,然后关闭该框架并贴上标签。
我要关闭的内容:
![image]:https://imgur.com/a/sO6rYJs
关闭框架及其标签后的外观:
![image]: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)
答案 0 :(得分:-1)
尝试
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()