开发者

Python/Tkinter: Getting the full Event name?

开发者 https://www.devze.com 2023-04-13 01:35 出处:网络
How do I get th开发者_开发问答e full name of an event? For example, Event.keysym only shows \"c\" for an event triggered by \"<Control-c>\". How can I get the \"Control\" too?Event.state holds t

How do I get th开发者_开发问答e full name of an event? For example, Event.keysym only shows "c" for an event triggered by "<Control-c>". How can I get the "Control" too?


Event.state holds the OR'd together states of the modifier keys. So you could try something like:

modifiers = []
if event.state & 1:
    modifiers.append('Shift')
if event.state & 4:
    modifiers.append('Control')
# ... etc
print '-'.join(modifiers)

See here for more details.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号