简体   繁体   English

[mac Monterey][Python 3.10.4][tkinter 8.6] 重复创建 window 时调用 tkinter askOpenfilename 崩溃

[英][mac Monterey][Python 3.10.4][tkinter 8.6] Calling tkinter askOpenfilename crashes when repeatedly creating a window

I have a python program that allows users to repeatedly press a key that will create a tkinter window where they can open an image an manipulate it.我有一个 python 程序,它允许用户重复按下一个键,该键将创建一个 tkinter window,他们可以在其中打开图像并对其进行操作。

The problem is, by the 3rd time, tkinter always crashes.问题是,到第三次时,tkinter 总是崩溃。

I can't figure out why..我想不通为什么..

I have simplified the code below:我简化了下面的代码:

import tkinter as tk
from tkinter import filedialog

class Application(tk.Frame):
    def __init__(self, root=None):

        super().__init__(root) 
        self.root = root
        filename = filedialog.askopenfilename(title='open')


def run(title):
    root = tk.Tk()
    root.title(title)
    root.geometry(str(100) + "x" + str(100))
    app = Application(root=root)

    app.mainloop()


def main():
    run("1")
    run("2")
    run("3")
    run("4")
    run("5")
    run("6")

if __name__ == '__main__':
    main()

Any help would be very useful.任何帮助都会非常有用。

The error message is long.错误信息很长。 But here is a relevant part:但这里有一个相关的部分:

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x000000000000001c
Exception Codes:       0x0000000000000001, 0x000000000000001c
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [10115]

There is no fix for this as of right now.目前还没有解决此问题的方法。 The Tk maintainers acknowledged the bug and are working on it. Tk 维护人员承认了这个错误并正在努力解决它。

Ref link is here参考链接在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM