Problem:
catch on_press() on text box and either define global to reference, then display the keyboard value in the text box.
The 'myObjectText' is defined in another function, so
HOW TO reference the object 'myObjectText' inside the on_press() event?
Use pynput library; but on open to ideas.
def on_press(key):
try:
if insidePoint(key, myObjectText):
myObjectText = key.char()
except AttributeError:
print('special key {0} pressed'.format(key))
Listener on_press defined:
Listener in main driver function, to list to on_press()
with Listener(on_press=on_press, on_release=on_release) as listener:
listener.join()
Text object defined:
creating 'myObjectText' in custom function
def makeTextGUI():
win = GraphWin("",300,200)
myObjectText = Text(Point(225,70),"")
myObjectText.draw(win)
Imports:
from graphics import *
from pynput import mouse
from pynput.keyboard import Key, Listener