Python IDLE 不接受引号
免责声明:我是菜鸟。
我已经在 OSX 10.6 上安装了 Python 3.2 (r32:88452) 和 ActiveTcl 8.5.9.2 (build 294317)。两者安装都没有任何错误,并且我已经成功通过终端运行 .PY。运行没问题。
我运行 IDLE 并且没有显示任何错误。但每当我按下引号键(')时,什么也没有发生。与按下 [shift] (") 相同。字符不会注册。按下 [shift] 或其他方式的“反引号”/波浪号键也会发生同样的情况。
我使用的是美国国际键盘布局。
我'我尝试打开键盘查看器。单引号和“反引号”这两个键都是橙色的(直到现在我才注意到。)在任何其他应用程序中,每当单击它们时,都会输入相应的字符--但 Python IDLE 中没有任何反应。
其他信息:交互模式下的 Python 解释器(从终端运行)可以很好地注册两个键 另外,如果我尝试更改键盘布局。对于简单的“US”,即使 IDLE 也会注册密钥;但这更像是一种解决方法,我想听听您的意见。
Disclaimer: I'm a noob.
I've installed Python 3.2 (r32:88452) and ActiveTcl 8.5.9.2 (build 294317) on my OSX 10.6. Both installed without any errors, and I've already managed to run a .PY through Terminal. It runs okay.
I run IDLE and it doesn't show any errors. But whenever I press the quote key ('), nothing happens. The same with [shift] pressed ("). The characters just don't register. The same happens with the 'backtick'/tilde key, [shift] pressed or otherwise.
I'm using a U.S. International keyboard layout.
I've tried opening the Keyboard Viewer. Both keys, single quote and 'backtick', are orange-colored. (I had never noticed that until now.) In any other application, whenever they're clicked, the corresponding character is input -- but nothing happens from within the Python IDLE.
Any ideas on what might be happening?
Additional information: Python interpreter in interactive mode (running it from Terminal) registers both keys just fine. Also, if I try and change the keyboard layout to plain "U.S.", even IDLE registers the keys; but this tastes more like a workaround and I'd like to hear your opinions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
IDLE 使用 Python 标准库中的
Tkinter
来提供 GUI 功能。 Tkinter 是多平台Tk
图形界面的接口,是Tcl/Tk
的一部分。不幸的是,OS X 上的 AquaTk
目前并不支持 OS X 上的所有标准文本处理功能。这个特定问题似乎是 Cocoa Aqua Tk 中已知错误的变体。在普通的 Apple US 键盘上,您可以使用
option U
+
形成分音符(例如ä
)。看起来在美国国际键盘上,使用的是'
键,而不是缺少的选项 u
。最新的 ActiveState Tk 8.5 版本(包括您安装的版本)中有一个补丁可以防止 Tk 在这种情况下崩溃。您可以通过启动 Mac OS X 10.6 中包含的 Apple 提供的 IDLE 2.6 (/usr/bin/idle2.6
) 来了解它过去如何“工作”。尝试在那里输入'
(使用国际键盘设置)或选项 U
(使用美国键盘设置)!修补后的版本只是忽略这种情况,而不是崩溃。最好的选择是坚持使用
US
或US Extended
键盘输入法。IDLE uses
Tkinter
from the Python standard library to supply GUI functionality. Tkinter is an interface to the multi-platformTk
graphical interface, part ofTcl/Tk
. Unfortunately, AquaTk
on OS X does not currently support all of the standard text processing features on OS X.This particular problem appears to be a variation of a known bug in the Cocoa Aqua Tk. On a normal Apple U.S. keyboard, you use
option U
+<vowel>
to form a diaeresis (for example,ä
). It looks like on the US International keyboard, the'
key is used instead of the missingoption u
. There is a patch in the most recent ActiveState Tk 8.5 versions (including the one you have installed) that prevents Tk from crashing in this case. You can see how it used to "work" by launching the Apple-supplied IDLE 2.6 included with Mac OS X 10.6 (/usr/bin/idle2.6
). Try typing'
(with the International keyboard setting) oroption U
(with the US keyboard setting) there! The patched version simply ignores this case, rather than crashing.Your best bet is to stick to a
US
orUS Extended
keyboard input method.更改为“普通美国”不是一种解决方法,而是一种解决方案,除非您出于某种原因确实想坚持使用美国国际布局。以下是有关美国国际布局的一些指南。
Changing to "plain US" is not a workaround but a solution for you, unless you really want to stick with U.S. International layout for some reason. Here are some guidelines on US International Layout.