Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3:在调用lambda函数后销毁tkinter窗口,而不退出程序_Python_Python 3.x_Tkinter - Fatal编程技术网

Python 3:在调用lambda函数后销毁tkinter窗口,而不退出程序

Python 3:在调用lambda函数后销毁tkinter窗口,而不退出程序,python,python-3.x,tkinter,Python,Python 3.x,Tkinter,所以,我想在需要时关闭Tkinter窗口 w = Button(root, text="Tryck här för att skriva till high score lista", command=lambda :high_score(attempts, computer_word_list_for_display)) w.pack(fill=X) 压力很大 我试过了 w = Button(root, text="Tryck här för att skriva till high

所以,我想在需要时关闭Tkinter窗口

w = Button(root, text="Tryck här för att skriva till high score lista", command=lambda :high_score(attempts, computer_word_list_for_display))   
w.pack(fill=X)
压力很大

我试过了

w = Button(root, text="Tryck här för att skriva till high score lista", command=lambda :high_score(attempts, computer_word_list_for_display), root.destroy())    
w.pack(fill=X)
但它只给我一个错误信息。有什么想法吗

这里是函数的整体

def render_game_after(attempts,computer_word_list_for_display):
    root = Tk()

    w = Label(root, text="Detta är spelmenyn. Här kommer några alternativ.", bg = "black",fg = "white")
    w.pack(fill=X)

    w = Button(root, text="Tryck här för att skriva till high score lista", command=lambda :high_score(attempts, computer_word_list_for_display))
    w.pack(fill=X)

    w = Button(root, text="Klicka här för att se ditt resultat i ett annat fönster",command= lambda:render_highscore(attempts, computer_word_list_for_display))
    w.pack(fill=X)

    w = Button(root, text="Tryck här för att avsluta spelet", command=lambda: quit())
    w.pack(fill=X)

    root.mainloop()

更好地创建函数ie

def on_quit(a, b):
   high_score(a, b)
   root.destroy()

w = Button(root, text="...", command=lambda:on_quit(attempts, computer_word_list_for_display))    

它将更具可读性。

我修复了代码的格式,但请检查它是否正确。您收到的错误消息是什么?谢谢!那么,按下按钮后,功能将被调用,窗口将关闭?