Python 中的移位和大写锁定状态

编程入门 行业动态 更新时间:2024-10-20 03:24:18
本文介绍了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:关键词]

本文发布于:2023-04-30 07:13:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1390637.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:状态   Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!