本文介绍了Python 中的移位和大写锁定状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
限时送ChatGPT账号..我正在使用 Python 2.5 编写 TkInter 应用程序,我需要找出大写锁定和换档键的状态(真或假).我已经在网上搜索了所有但找不到解决方案.
I'm writing a TkInter application using Python 2.5 and I need to find out the status of the caps lock and shift keys (either true or false). I've searched all over the net but cant find a solution.
推荐答案
Tkinter 中的键盘事件可能很棘手.
Keyboard events in Tkinter can be tricky.
我建议您按顺序查看以下内容:
I suggest you have a look at the following, in order:
http://effbot/tkinterbook/tkinter-events-and-bindings.htmhttp://infohost.nmt.edu/tcc/help/pubs/tkinter/events.html(阅读关于事件的整章)http://www.faqts/knowledge_base/view.phtml/aid/4281 http://effbot/tkinterbook/tkinter-events-and-bindings.htm http://infohost.nmt.edu/tcc/help/pubs/tkinter/events.html (read the whole chapter on events) http://www.faqts/knowledge_base/view.phtml/aid/4281这是一个显示键码和状态事件参数值的程序.您可以使用它进行实验.点击窗口,然后敲击键盘.
Here is a program that displays the value of the keycode and state event parameters. You can use this to experiment. Click in the window, then hit the keyboard.
from Tkinter import *
root = Tk()
def key(event):
print "Keycode:", event.keycode, "State:", event.state
def callback(event):
frame.focus_set()
print "clicked at", event.x, event.y
frame = Frame(root, width=100, height=100)
frame.bind("<Key>", key)
frame.bind("<Button-1>", callback)
frame.pack()
root.mainloop()
这篇关于Python 中的移位和大写锁定状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论