为什么在我的函数中输入Entry Widget会使python完全崩溃?

时间:2019-05-20 20:19:01

标签: python tkinter

我使用Tkinter编写了很长的代码,但是根本无法使用。我不断收到一条巨大的错误消息,然后出现一个Python选项卡,告诉我它已崩溃。我在Pycharm上尝试过,通常在Terminal上尝试过,但都没有用。 (Mac)

我不确定这个问题,所以我不断缩小范围。我已经确定的是,每当我在函数中使用入口小部件时,代码都会崩溃。这在我的PC上有效,但在我的mac上不起作用。香港专业教育学院尝试使用Conda,并更新Python,但我是一个真正的初学者,所以我不知道我在做什么。

from tkinter import *
from tkinter import Tk, Button, Frame, Entry, END


def the_graph():
    yeet = entry_1.get()
    return yeet

my_window = Tk()



button_1 = Button(my_window, text=" Just work please. ", command=the_graph)

label_1 = Label(my_window, text=" Label 1")
entry_1 = Entry(my_window)


label_1.grid(row=0, column=0)
entry_1.grid(row=0, column=1)
button_1.grid(row=29, column=0)

my_window.title('my window')
my_window.mainloop()


出现错误消息:

2019-05-21 00:01:59.598 Python[30864:3667592] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x7f8e646f7230'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff3b2bc43d __exceptionPreprocess + 256
    1   libobjc.A.dylib                     0x00007fff671ca720 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff3b339255 -[NSObject(NSObject) __retain_OA] + 0
    3   CoreFoundation                      0x00007fff3b25bad0 ___forwarding___ + 1486
    4   CoreFoundation                      0x00007fff3b25b478 _CF_forwarding_prep_0 + 120
    5   libtk8.6.dylib                      0x000000011c14f1f2 TkpInit + 408
    6   libtk8.6.dylib                      0x000000011c0beaac Initialize + 2454
    7   _tkinter.cpython-37m-darwin.so      0x000000011bf20dc4 Tcl_AppInit + 84
    8   _tkinter.cpython-37m-darwin.so      0x000000011bf20a98 _tkinter_create + 1144
    9   Python                              0x000000010a1434ee _PyMethodDef_RawFastCallKeywords + 430
    10  Python                              0x000000010a142a5a _PyCFunction_FastCallKeywords + 42
    11  Python                              0x000000010a2015a4 call_function + 724
    12  Python                              0x000000010a1fe576 _PyEval_EvalFrameDefault + 25190
    13  Python                              0x000000010a2020d6 _PyEval_EvalCodeWithName + 2422
    14  Python                              0x000000010a1425fb _PyFunction_FastCallDict + 523
    15  Python                              0x000000010a1438cf _PyObject_Call_Prepend + 143
    16  Python                              0x000000010a191d51 slot_tp_init + 145
    17  Python                              0x000000010a18d6a9 type_call + 297
    18  Python                              0x000000010a142871 _PyObject_FastCallKeywords + 433
    19  Python                              0x000000010a201474 call_function + 420
    20  Python                              0x000000010a1fe617 _PyEval_EvalFrameDefault + 25351
    21  Python                              0x000000010a2020d6 _PyEval_EvalCodeWithName + 2422
    22  Python                              0x000000010a1f8234 PyEval_EvalCode + 100
    23  Python                              0x000000010a2358f1 PyRun_FileExFlags + 209
    24  Python                              0x000000010a23516a PyRun_SimpleFileExFlags + 890
    25  Python                              0x000000010a2549db pymain_main + 6875
    26  Python                              0x000000010a254f2a _Py_UnixMain + 58
    27  libdyld.dylib                       0x00007fff68298085 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

0 个答案:

没有答案