tkinter root.destroy()挂在MacOS Catalina 10.15.1上

时间:2019-11-30 08:43:09

标签: tkinter python-3.6 jupyter macos-catalina

在Jupyter笔记本中执行以下单元格,这将导致无限旋转的沙滩球,唯一的出路是强制退出python。也尝试了root.quit()选项。退出tkinter主循环的简单方法是什么?

from tkinter import *
from tkinter import ttk

root = Tk()
root.geometry('550x250+200+75')

root.title('Dummy Application')

mainframe = ttk.Frame(root,
                      padding = '10',
                      borderwidth = 4,
                      relief = 'raised')

mainframe.grid(column=0,
               row=0,
               sticky=(N, W, E, S))

root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)

ttk.Label(mainframe,
          text='\nHypothetical first line of instructions\
\nSimply close this window to quit the application,\
\nor hit the "QUIT" button...\n').grid(column=1, columnspan = 2,
                                        row=1,
                                        sticky = W)
quit_button = ttk.Button(mainframe,
                     text = 'QUIT',
                     command = root.destroy)

quit_button.grid(column = 2,
                 row = 2,
                 sticky = W)

for child in mainframe.winfo_children():
    child.grid_configure(padx=5, pady=5)

root.mainloop()

0 个答案:

没有答案