在Tkin绘制烛台

2024-09-25 06:26:18 发布

您现在位置:Python中文网/ 问答频道 /正文

有人知道如何在特金特画一个简单的烛台吗?我试图使用下面的MatPlotLib website中的代码并在sublimetext3运行它。但是,尝试了这么多次后,tkinter无法打开,我一直收到这样的警告:

2016-07-26 13:38:46.546 Python[88018:4981017] -[NSApplication _setup:]: unrecognized selector sent to instance 0x106c42df0
2016-07-26 13:38:46.574 Python[88018:4981017] An uncaught exception was raised
2016-07-26 13:38:46.574 Python[88018:4981017] -[NSApplication _setup:]: unrecognized selector sent to instance 0x106c42df0
2016-07-26 13:38:46.574 Python[88018:4981017] (
    0   CoreFoundation                      0x00007fff917474f2 __exceptionPreprocess + 178
    1   libobjc.A.dylib                     0x00007fff966a573c objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff917b11ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x00007fff916b7571 ___forwarding___ + 1009
    4   CoreFoundation                      0x00007fff916b70f8 _CF_forwarding_prep_0 + 120
    5   Tk                                  0x0000000101677948 TkpInit + 476
    6   Tk                                  0x00000001015f2a6e Tk_Init + 1799
    7   _tkinter.cpython-35m-darwin.so      0x00000001003f0dcd Tcl_AppInit + 77
    8   _tkinter.cpython-35m-darwin.so      0x00000001003ee7d9 _tkinter_create + 889
    9   Python                              0x0000000100065479 PyCFunction_Call + 233
    10  Python                              0x00000001000f1631 PyEval_EvalFrameEx + 36305
    11  Python                              0x00000001000f2510 _PyEval_EvalCodeWithName + 2368
    12  Python                              0x00000001000f038b PyEval_EvalFrameEx + 31531
    13  Python                              0x00000001000f2510 _PyEval_EvalCodeWithName + 2368
    14  Python                              0x00000001000f2617 PyEval_EvalCodeEx + 71
    15  Python                              0x000000010004031a function_call + 186
    16  Python                              0x000000010000d713 PyObject_Call + 99
    17  Python                              0x00000001000286fc method_call + 140
    18  Python                              0x000000010000d713 PyObject_Call + 99
    19  Python                              0x0000000100082a01 slot_tp_init + 81
    20  Python                              0x0000000100079624 type_call + 212
    21  Python                              0x000000010000d713 PyObject_Call + 99
    22  Python                              0x00000001000ec852 PyEval_EvalFrameEx + 16370
    23  Python                              0x00000001000f2510 _PyEval_EvalCodeWithName + 2368
    24  Python                              0x00000001000f2671 PyEval_EvalCode + 81
    25  Python                              0x000000010012083e PyRun_FileExFlags + 206
    26  Python                              0x0000000100120adf PyRun_SimpleFileExFlags + 447
    27  Python                              0x0000000100139858 Py_Main + 3512
    28  Python                              0x0000000100000e32 Python + 3634
    29  Python                              0x0000000100000c84 Python + 3204
    30  ???                                 0x0000000000000003 0x0 + 3
)
2016-07-26 13:38:46.575 Python[88018:4981017] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x106c42df0'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff917474f2 __exceptionPreprocess + 178
    1   libobjc.A.dylib                     0x00007fff966a573c objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff917b11ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x00007fff916b7571 ___forwarding___ + 1009
    4   CoreFoundation                      0x00007fff916b70f8 _CF_forwarding_prep_0 + 120
    5   Tk                                  0x0000000101677948 TkpInit + 476
    6   Tk                                  0x00000001015f2a6e Tk_Init + 1799
    7   _tkinter.cpython-35m-darwin.so      0x00000001003f0dcd Tcl_AppInit + 77
    8   _tkinter.cpython-35m-darwin.so      0x00000001003ee7d9 _tkinter_create + 889
    9   Python                              0x0000000100065479 PyCFunction_Call + 233
    10  Python                              0x00000001000f1631 PyEval_EvalFrameEx + 36305
    11  Python                              0x00000001000f2510 _PyEval_EvalCodeWithName + 2368
    12  Python                              0x00000001000f038b PyEval_EvalFrameEx + 31531
    13  Python                              0x00000001000f2510 _PyEval_EvalCodeWithName + 2368
    14  Python                              0x00000001000f2617 PyEval_EvalCodeEx + 71
    15  Python                              0x000000010004031a function_call + 186
    16  Python                              0x000000010000d713 PyObject_Call + 99
    17  Python                              0x00000001000286fc method_call + 140
    18  Python                              0x000000010000d713 PyObject_Call + 99
    19  Python                              0x0000000100082a01 slot_tp_init + 81
    20  Python                              0x0000000100079624 type_call + 212
    21  Python                              0x000000010000d713 PyObject_Call + 99
    22  Python                              0x00000001000ec852 PyEval_EvalFrameEx + 16370
    23  Python                              0x00000001000f2510 _PyEval_EvalCodeWithName + 2368
    24  Python                              0x00000001000f2671 PyEval_EvalCode + 81
    25  Python                              0x000000010012083e PyRun_FileExFlags + 206
    26  Python                              0x0000000100120adf PyRun_SimpleFileExFlags + 447
    27  Python                              0x0000000100139858 Py_Main + 3512
    28  Python                              0x0000000100000e32 Python + 3634
    29  Python                              0x0000000100000c84 Python + 3204
    30  ???                                 0x0000000000000003 0x0 + 3
)
libc++abi.dylib: terminating with uncaught exception of type NSException
[Finished in 1.3s with exit code -6]

以下是我目前掌握的代码:

^{pr2}$

Tags: totkinterexceptioncallcpythontkpyobjectforwarding