I have been trying to make a simple game, and have recently been trying to work on a menu system for it. I am trying to insert a TextEntry box using the examples they have provided themselves.
I have attempted to replicate their code, however I cannot enter any text with the TextEntry. The other widgets work fine, it is just this one. I am unsure if I need to call it into focus, but there does not appear to be any way to do so.
The relevant code is as such:
import pyglet
window = pyglet.window.Window(540, 500, caption="Widget Example")
batch = pyglet.graphics.Batch()
pyglet.gl.glClearColor(0.8, 0.8, 0.8, 1.0)
@window.event
def on_draw():
window.clear()
batch.draw()
def text_entry_handler(text):
text_entry_label.text = f"Text: {text}"
frame = pyglet.gui.Frame(window, order=4)
text_entry = pyglet.gui.TextEntry("Enter Your Name", 100, 100, 150, batch=batch)
frame.add_widget(text_entry)
text_entry.set_handler('on_commit', text_entry_handler)
text_entry_label = pyglet.text.Label("Text: None", x=300, y=100, batch=batch, color=(0, 0, 0, 255))
pyglet.app.run()
Any help would be appreciated.