2017-03-08 5 views
0

Ich habe etwas Code geerbt, der kivy/tkinter/matplotlib verwendet, die gut auf Windows laufen, aber einige Probleme auf OSX hat. Ein Problem wurde bereits in another question gelöst. Ich erhalte eine NSException wenn ich laufe die folgenden:NSException in kivy mit matplotlib und tkinter

import tkinter 
# tkinter._test() 

import matplotlib 
matplotlib.use("TkAgg") 
from matplotlib import pyplot as plt 
import kivy.core.window 

from tkinter.filedialog import askopenfilename 

askopenfilename(initialdir='/', title="Open files") 

Ich habe nicht die Ausnahme, wenn ich askopenfilename nennen. Jetzt dachte ich "vielleicht tkinter funktioniert nicht" also warf ich den ersten tkinter._test() ein, der dann sagt, dass alles in Ordnung ist ... und wenn der Code danach weiterläuft, tritt die Ausnahme nicht auf und alles läuft einfach fein.

Also meine Frage ist, was ist in der Regel die Wurzel und die Natur dieser NSExceptions, und was könnte tkinter._test() tun, dass es nicht auftritt?

Und wie repliziere ich, was es tut, ohne das unerwünschte anfängliche Testpopup zu haben?

Die geworfene Ausnahme ist:

2017-03-08 15:16:00.199 Python[31489:260345] -[SDLApplication _setup:]: unrecognized selector sent to instance 0x1021727f0 
2017-03-08 15:16:00.203 Python[31489:260345] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SDLApplication _setup:]: unrecognized selector sent to instance 0x1021727f0' 
*** First throw call stack: 
(
    0 CoreFoundation      0x00007fffa8716e7b __exceptionPreprocess + 171 
    1 libobjc.A.dylib      0x00007fffbd300cad objc_exception_throw + 48 
    ... 
    53 Python        0x0000000100000c34 Python + 3124 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 

Antwort

0

Also ich fühle mich dumm, war der Grund einfach, dass _test() erzeugt ein Root-Fenster, und die große Lösung ist nur ein Root-Fenster erstellen nach dem Import:

import tkinter 
root = tkinter.Tk() 
root.withdraw() 
Verwandte Themen