Python Forum

Full Version: problems with pyglet error catching
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there. While I was trying to use pyglet on windows, I tried making a test screen that would raise a runtime error as soon as I was going to press the key R. Code looks like this
from pyglet import app
from pyglet.window import Window, key

win = Window(caption='test application')
@win.event
def on_key_press(symbol, modifiers):
    if symbol == key.R:
        raise RuntimeError("this is a test")
app.run()
though, when I execute it, the window pops up, but if I press r, nothing happens.
I had issues like this with other projects, where if I had an error at runtime for example from an imported file, nothing would happen and the eventloop would run nomatter what.
Is this me being wrong, or is this an issue?
Thanks in advance.
Your could works fine for me.
Maybe instead of raise RuntimeError.
print("print this is a test")
or do both.