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

  • SEARCH
  • Home
  • 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 8087577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:49:17+00:00 2026-06-05T18:49:17+00:00

The following code is an alternative to the usual style (using decorators) pyglet makes

  • 0

The following code is an alternative to the usual style (using decorators) pyglet makes use of.

Can anyone explain how the on_draw() method is called here?

import pyglet

class HelloWorldWindow(pyglet.window.Window): 
    def __init__(self):
        super(HelloWorldWindow, self).__init__() 
        self.label = pyglet.text.Label('Hello, world!') 

    def on_draw(self):
        self.clear() 
        self.label.draw() 

if __name__ == '__main__':
    window = HelloWorldWindow() 
    pyglet.app.run()

The code written using decorators can be found here.

  • 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-06-05T18:49:19+00:00Added an answer on June 5, 2026 at 6:49 pm

    You can just dig through the source to find the answer.

    The EventLoop class (you use it by pyglet.app.run()) dispatches the on_draw event regulary.

    From the source:

    Calling run begins the application event loop, which processes
    operating system events, calls pyglet.clock.tick to call scheduled
    functions and calls pyglet.window.Window.on_draw and
    pyglet.window.Window.flip to update window contents.

    The Window class subscripes to this event:

    BaseWindow.register_event_type('on_draw')
    

    So by subclassing Window, you ensure your on_draw method gets called.

    Look at the programming guide for an example of how the event system of pyglet works.

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

Sidebar

Related Questions

Can anyone provide either a method of using the following code that doesn't result
The following code doesn't work, can someone suggest an alternative, if ((!defined('admin')) || !defined('moderator'))
I am using the following code to send out a Multipart/Alternative HTML and Plain
I have a problem using the following code to set background of UITAbleview. Can
I have the following code alternatives, neither of which is satisfactory. I'm using jQuery
Following code is generated by a for loop. <form action=saveresponse.php method=POST name=mainForm> <input class=cbox_yes
I'd like to know if there is a better alternative to my following code
I'm using the following code to hide stderr on Linux/OSX for a Python library
I am using the following code to get an xml string. public static string
Can someone kindly enlighten me why the following code of mine does not work?

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.