This commit is contained in:
Xevion
2019-07-25 22:21:56 -06:00
parent 4d47e92610
commit 5948e26c4e
25 changed files with 1139 additions and 0 deletions

33
key_click_events.py Normal file
View File

@@ -0,0 +1,33 @@
from tkinter import *
# I have no honest idea of what is going on here, but it works, so that's cool.
class Application(Frame):
def __init__(self, master):
Frame.__init__(self, master)
self.master.minsize()
self.master.config()
self.labelvar = StringVar()
self.master.bind('<Key>', lambda event:self.met(event))
# Bind seems to pass an event, lambda can handle it and pass this event to a def
self.frame = Frame() # Frame within Frame? Hmm?
self.frame.pack(fill='both', expand=True)
self.label = Label(self, textvariable=self.labelvar) # Label for Keyboard String
self.label.pack()
self.pack()
# Handles keyboard updates, passes then to key(event) for printing without flush
def met(self, event):
self.key(event)
self.labelvar.set(event.keysym)
@staticmethod
def key(event):
print(event.keysym, end=' ', flush=True)
root = Tk()
root.wm_attributes("-topmost", 1)
app = Application(root)
root.mainloop()