gpt4 book ai didi

python - 在 Tkinter 中绑定(bind) '<' key

转载 作者:行者123 更新时间:2023-12-01 09:07:45 24 4
gpt4 key购买 nike

这是一个简单的问题,有没有办法获取字符的ASCII码进行绑定(bind)或者其他什么?我在提出问题之前搜索了 aswners

最佳答案

绑定(bind)到<您需要绑定(bind)到事件 <less>

了解某些不常见键的绑定(bind)内容的一个方便技巧是编写一个程序来显示您按下的每个键的键符号。例如:

import tkinter as tk
root = tk.Tk()
label = tk.Label(root, width=20, height=2, font=("Helvetica", 24))
label.pack(fill="both", padx=10, pady=10)
root.bind("<Any-KeyPress>",
lambda event: label.configure(text=event.keysym))
root.focus_set()
root.mainloop()

关于python - 在 Tkinter 中绑定(bind) '<' key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51911073/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com