【发布时间】:2013-11-26 17:36:11
【问题描述】:
我最近买了一个新的 macbook pro,我一直在用它来处理 python。 Python 已经安装好了,我的版本是 2.7.5。
但是 tkinter 根本无法处理 IDLE 或 sublime 文本!我没有收到错误或任何东西,只是当我输入我的代码时什么都没有显示!
这是我使用的示例代码:
Python 2.7.5 (default, Sep 2 2013, 05:24:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> from Tkinter import *
>>> tk = Tk()
>>> btn = Button (tk, text = "click me")
>>> btn.pack
<bound method Button.pack_configure of <Tkinter.Button instance at 0x101b4edd0>>
>>> btn.pack()
编辑:我最终只是从互联网上下载了 python idle(3.3 版)并获得了它附带的空闲,现在我只是使用它。然而,它根本没有针对视网膜进行优化,这使得使用起来非常痛苦。我现在只是使用 Windows 7 来做。不过还是谢谢你的回答
【问题讨论】:
-
如果你把那个代码放在一个文件中,添加一个对 mainloop 的调用,然后执行这个文件,会发生什么?