era mas facil de lo que pense, ahora podre seguir avanzando en la logica del codigo.
Código Python:
Ver originalimport threading
from tkinter import *
from pynput import keyboard
def on_press(key):
try:
print('1- pressed' + str(key))
except AttributeError:
print('2- pressed' + str(key))
def on_release(key):
#print('3- released' + str(key))
if key == keyboard.Key.esc:
return False
def escuchar():
with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
listener.join()
def ventana():
master = Tk()
w = Label(master, text="Hello, world!")
w.pack()
mainloop()
hilo1 = threading.Thread(target = ventana)
hilo2 = threading.Thread(target = escuchar)
hilo1.start()
hilo2.start()