Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4020456
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:13:50+00:00 2026-05-20T10:13:50+00:00

In the pyglet docs, I found: The following example shows how to grab a

  • 0

In the pyglet docs, I found:

The following example shows how to
grab a screenshot of your application
window:
pyglet.image.get_buffer_manager().get_color_buffer().save('screenshot.png')

However when using this, everything will stop until I click the mouse. Is there another way to get the screen contents in Pyglet, or to force it back into the event loop?

EDIT: I have found that actually there is a short delay (0.2 seconds~), but nothing else. Actually it is something to do with the F10 key that stops pyglet. >_>

I cannot close or delete since there is an open bounty.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:13:51+00:00Added an answer on May 20, 2026 at 10:13 am

    Okay, here is a complete working example in pyglet. It shows the text “hello world” taking a random walk around the window and dumps the screenshot (using the exact same line of code you posted) every time you press a key.

    import pyglet, random
    
    window = pyglet.window.Window()
    
    label = pyglet.text.Label('Hello, world',
                              font_name='Times New Roman',
                              font_size=36,
                              x=window.width//2, y=window.height//2,
                              anchor_x='center', anchor_y='center')
    @window.event
    def on_draw():
        window.clear()
        label.draw()
    
    @window.event
    def on_key_press(symbol, modifiers):
        pyglet.image.get_buffer_manager().get_color_buffer().save('screenshot.png')
    
    def update(dt):
        label.x += random.randint(-10, 10)
        label.y += random.randint(-10, 10)
    
    pyglet.clock.schedule_interval(update, 0.1)
    pyglet.app.run()
    

    Taking the screenshot doesn’t halt the event loop. The event loop in pyglet is just lazy, and tries to do as little work as possible. You need to schedule a function to run repeatedly if you want things to keep happening on their own. Otherwise, it’ll wait for an event that has a listener attached to happen. (Your code must be listening for the mouse event, which is why it resumes work when you click the mouse.)

    Short answer, I suspect the fix you need is pyglet.clock.schedule_interval(...).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to convert a Pyglet.AbstractImage object to an PIL image for further manipulation
I have a pyglet window that has a attribute observer. The observer has a
Is there a way to set individual pixel values for image data in Pyglet?
I've been playing with pyglet . It's very nice. However, if I run my
I'm trying to implement picking using Pyglet's OpenGL wrapper, but I'm having trouble converting
I am building a tile based app in Python using pyglet/openGL wherein I'll need
Pygame and Pyglet are for 2D game development. Pysoy needs many requirements to be
I'm using pyglet for my OpenGL based game but is it the fastest library
How can one display and scroll through a multi-line strings (contain \n) via pyglet
I'm new to pyglet and i have a problem with video.. I'm trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.