Vel*_*lus 16 python keyboard tkinter input
(2013年)我不知道为什么Python很奇怪,你不能通过谷歌搜索很容易找到这个,但它很简单.
如何检测"SPACE"或实际上是否有任何键?我怎样才能做到这一点:
print('You pressed %s' % key)
Run Code Online (Sandbox Code Playgroud)
这应该包含在python核心中,所以请不要链接与核心python无关的模块.
unu*_*tbu 20
你可以制作一个小Tkinter应用程序:
import Tkinter as tk
def onKeyPress(event):
text.insert('end', 'You pressed %s\n' % (event.char, ))
root = tk.Tk()
root.geometry('300x200')
text = tk.Text(root, background='black', foreground='white', font=('Comic Sans MS', 12))
text.pack()
root.bind('<KeyPress>', onKeyPress)
root.mainloop()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
101064 次 |
| 最近记录: |