0
\$\begingroup\$

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.

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

1 Answer 1

1
\$\begingroup\$

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:

@window.event
def on_draw():
    window.clear()

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

\$\endgroup\$
2
  • \$\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
    Commented Mar 20, 2016 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\$
    – user35344
    Commented Mar 20, 2016 at 18:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .