I use the following code in the python command line interpreter, but the window doesn't respond.

import pyglet
window = pyglet.window.Window()

A white window with python icon into left-upper corner appears but then it basically hangs. Windows task manager shows that this window is not responding. However the Python command prompt works well. No errors or warning messages get displayed.

  • 1
    \$\begingroup\$ you probably need an event loop that checks for input/window updates \$\endgroup\$ – CobaltHex Mar 20 '16 at 9:23

You need to add an event loop for your window. The following code is directly from a pyglet quickstart tutorial.

You basically need a function that gets called periodically. After that you can then just ask pyglet to run the application. Here's a basic draw function:

def on_draw():

and then just call pyglet.app.run() to start the app.

  • \$\begingroup\$ After 'window = pyglet.window.Window()' I add only 'pyglet.app.run()' and it works. Maybe it's because the window has no any events or content? \$\endgroup\$ – neuro Mar 20 '16 at 18:07
  • \$\begingroup\$ Yes, that should also work. I was just trying to let you know a little about the underlaying structure. Please feel free to accept my answer and upvote it if it solves your problem. \$\endgroup\$ – Tyyppi_77 Mar 20 '16 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.