chetan-set
chetan-set

Reputation: 35

[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.

The problem is, by the 3rd time, tkinter always crashes.

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]

Upvotes: 0

Views: 532

Answers (1)

chetan-set
chetan-set

Reputation: 35

There is no fix for this as of right now. The Tk maintainers acknowledged the bug and are working on it.

Ref link is here

Upvotes: 1

Related Questions