添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
玩足球的红薯  ·  API: Filters·  1小时前    · 
被表白的围巾  ·  API: Basic Objects·  1小时前    · 
有腹肌的猕猴桃  ·  API: Projects·  1小时前    · 
虚心的排球  ·  API: Time Entries·  1小时前    · 
纯真的冲锋衣  ·  API: Statuses·  1小时前    · 
迷茫的皮带  ·  Welcome to Ozark ...·  1 周前    · 
憨厚的香烟  ·  南京市浦口区人民政府·  2 周前    · 
英俊的脆皮肠  ·  JSDoc and TypeScript ...·  2 月前    · 
卖萌的滑板  ·  sql server锁表 - CSDN文库·  2 月前    · 
command=lambda: root.quit()

This will call root.quit() and pass its result to the function.

That should be:

command=lambda: root.quit
              

tried suggestion , still not exiting when click button
thank for reply

import tkinter as tk
from tkinter import ttk
# root window
root = tk.Tk()
root.geometry('300x200')
root.resizable(False, False)
root.title('Button Demo')
# exit button
exit_button = ttk.Button(
    root,
    text='Exit',
    command = root.quit
exit_button.pack(
    ipadx=5,
    ipady=5,
    expand=True
root.mainloop()

as Cameron said.

However, your original code does work.

Were you running it from a Python prompt?

If yes, then root.mainloop() will finish and the prompt will return, but the window will remain because the tkinter module still has a reference to it. That’s not a problem when you’re running a script because you’ll be quitting the Python interpreter just afterwards, but you can close that window by using root.destroy() instead.

am using IDLE (Python 3-11 64-bit)

run in visual studio code , and it worked there

wonder what the problem is with IDLE , though it is simpler to use than VS code

thanks