gpt4 book ai didi

python - 使用 Python 和 Tkinter 制作一个简单的 GUI,我将无法识别的选择器发送到实例

转载 作者:可可西里 更新时间:2023-11-01 10:05:15 26 4
gpt4 key购买 nike

我正在尝试学习如何使用 Python 制作 GUI 程序。我正在使用 Python 2.7.6。下面是带有标签的简单窗口的代码:

from Tkinter import *
root = Tk()
label = Label(root, text="hello")
label.pack()

root.mainloop()

此代码适用于我的 Windows 7 计算机,但不适用于我的 Mac OSX 10.10.4。在 Mac 上我收到以下错误:

    2015-08-18 10:32:09.137 Python[11678:5520486] -[QNSApplication_setup:]: unrecognized selector sent to instance 0x10f83bd10
2015-08-18 10:32:09.137 Python[11678:5520486] -[QNSApplication _setup:]: unrecognized selector sent to instance 0x10f83bd10
2015-08-18 10:32:09.139 Python[11678:5520486] (
0 CoreFoundation 0x00007fff8ccc303c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8ee8a76e objc_exception_throw + 43
2 CoreFoundation 0x00007fff8ccc60ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00007fff8cc0be24 ___forwarding___ + 1028
4 CoreFoundation 0x00007fff8cc0b998 _CF_forwarding_prep_0 + 120
5 Tk 0x00000001199b1527 TkpInit + 476
6 Tk 0x000000011992baca Tk_Init + 1788
7 _tkinter.so 0x0000000110b01ceb Tcl_AppInit + 75
8 _tkinter.so 0x0000000110afef14 Tkinter_Create + 916
9 Python 0x00000001000c6ced PyEval_EvalFrameEx + 25213
10 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
11 Python 0x00000001000419e0 function_call + 176
12 Python 0x000000010000fe02 PyObject_Call + 98
13 Python 0x000000010002251b instancemethod_call + 363
14 Python 0x000000010000fe02 PyObject_Call + 98
15 Python 0x00000001000bf7b7 PyEval_CallObjectWithKeywords + 87
16 Python 0x000000010002580e PyInstance_New + 126
17 Python 0x000000010000fe02 PyObject_Call + 98
18 Python 0x00000001000c4138 PyEval_EvalFrameEx + 14024
19 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
20 Python 0x00000001000c90d6 PyEval_EvalCode + 54
21 Python 0x00000001000edc2e PyRun_FileExFlags + 174
22 Python 0x00000001000bdb6c builtin_execfile + 364
23 Python 0x00000001000c7132 PyEval_EvalFrameEx + 26306
24 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
25 Python 0x00000001000419e0 function_call + 176
26 Python 0x000000010000fe02 PyObject_Call + 98
27 Python 0x00000001000c1d2d PyEval_EvalFrameEx + 4797
28 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
29 Python 0x00000001000419e0 function_call + 176
30 Python 0x000000010000fe02 PyObject_Call + 98
31 Python 0x00000001000c1d2d PyEval_EvalFrameEx + 4797
32 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
33 Python 0x00000001000c68ad PyEval_EvalFrameEx + 24125
34 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
35 Python 0x00000001000c68ad PyEval_EvalFrameEx + 24125
36 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
37 Python 0x00000001000419e0 function_call + 176
38 Python 0x000000010000fe02 PyObject_Call + 98
39 Python 0x00000001000c1d2d PyEval_EvalFrameEx + 4797
40 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
41 Python 0x00000001000c68ad PyEval_EvalFrameEx + 24125
42 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
43 Python 0x00000001000419e0 function_call + 176
44 Python 0x000000010000fe02 PyObject_Call + 98
45 Python 0x00000001000c1d2d PyEval_EvalFrameEx + 4797
46 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
47 Python 0x00000001000c68ad PyEval_EvalFrameEx + 24125
48 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
49 Python 0x00000001000c68ad PyEval_EvalFrameEx + 24125
50 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
51 Python 0x00000001000c85df PyEval_EvalFrameEx + 31599
52 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
53 Python 0x00000001000c68ad PyEval_EvalFrameEx + 24125
54 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
55 Python 0x00000001000c68ad PyEval_EvalFrameEx + 24125
56 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
57 Python 0x00000001000c68ad PyEval_EvalFrameEx + 24125
58 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
59 Python 0x00000001000c68ad PyEval_EvalFrameEx + 24125
60 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
61 Python 0x00000001000c68ad PyEval_EvalFrameEx + 24125
62 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
63 Python 0x00000001000419e0 function_call + 176
64 Python 0x000000010000fe02 PyObject_Call + 98
65 Python 0x00000001000c1d2d PyEval_EvalFrameEx + 4797
66 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
67 Python 0x00000001000419e0 function_call + 176
68 Python 0x000000010000fe02 PyObject_Call + 98
69 Python 0x00000001000c1d2d PyEval_EvalFrameEx + 4797
70 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
71 Python 0x00000001000c68ad PyEval_EvalFrameEx + 24125
72 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
73 Python 0x00000001000c68ad PyEval_EvalFrameEx + 24125
74 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
75 Python 0x00000001000c68ad PyEval_EvalFrameEx + 24125
76 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
77 Python 0x00000001000c68ad PyEval_EvalFrameEx + 24125
78 Python 0x00000001000c8fb9 PyEval_EvalCodeEx + 2137
79 Python 0x00000001000419e0 function_call + 176
80 Python 0x000000010000fe02 PyObject_Call + 98
81 Python 0x00000001000bf7b7 PyEval_CallObjectWithKeywords + 87
82 libpyside-python2.7.1.2.2.dylib 0x0000000102c67faa _ZN6PySide13SignalManager20callPythonMetaMethodERK11QMetaMethodPPvP7_objectb + 122
)

如果您能帮助理解为什么它在 Windows 计算机上运行但在 Mac 上运行不正常,我们将不胜感激。

谢谢

最佳答案

您从什么运行脚本?虚度? OSX 上的 TK 和 IDLE 存在一个已知问题。

https://www.python.org/download/mac/tcltk/

需要安装最新版本的 Tcl/Tk,如果您使用的是 IDLE,请尝试不同的环境。

关于python - 使用 Python 和 Tkinter 制作一个简单的 GUI,我将无法识别的选择器发送到实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32078005/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com