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 307835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:35:42+00:00 2026-05-12T07:35:42+00:00

I recently asked this question in the pyglet-users group, but got response, so I’m

  • 0

I recently asked this question in the pyglet-users group, but got response, so I’m trying here instead.

I would like to extend Pyglet to be able to use an infra red input device supported by lirc. I’ve used pyLirc before ( http://pylirc.mccabe.nu/ ) with PyGame and I want to rewrite my application to use Pyglet instead.

To see if a button was pressed you would typically poll pyLirc to see if there is any button presses in its queue.

My question is, what is the correct way in Pyglet to integrate pyLirc?

I would prefer if it works in the same was as the current window keyboard/mouse events, but I’m not sure where to start.

I know I can create a new EventDispatcher, in which I can register the
new types of events and dispatch them after polling, like so:

class pyLircDispatcher(pyglet.event.EventDispatcher):
    def poll(self):
        codes = pylirc.nextcode()
        if codes is not None:
            for code in codes:
                self.dispatch_event('on_irbutton', code)

    def on_irbutton(self, code):
        pass

But how do I integrate that into the application’s main loop to keep on calling poll() if I use pyglet.app.run() and how do I attach this eventdispatcher to my window so it works the same as the mouse and keyboard dispatchers?

I see that I can set up a scheduler to call poll() at regular intervals with pyglet.clock.schedule_interval, but is this the correct way to do it?

  • 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-12T07:35:42+00:00Added an answer on May 12, 2026 at 7:35 am

    It’s probably too late for the OP, but I’ll reply anyway in case it’s helpful to anyone else.

    Creating the event dispatcher and using pyglet.clock.schedule_interval to call poll() at regular intervals is a good way to do it.

    To attach the event dispatcher to your window, you need to create an instance of the dispatcher and then call its push_handlers method:

    dispatcher.push_handlers(window)
    

    Then you can treat the events just like any other events coming into the window.

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

Sidebar

Related Questions

I recently asked this question: Expose XML or Objects - thanks all for the
I recently asked this question and worked out that the reason a single email
This question is related to this other question I recently asked... cf.net exception and
Why are 'out' parameters in .NET a bad idea? I was recently asked this,
Recently I was asked this during a job interview. I was honest and said
I recently asked a question about IIf vs. If and found out that there
I recently asked a question about what I called method calls. The answer referred
I recently asked a question about Oracle Encryption. Along the way to finding a
I recently asked a question about tracing Linq-to-Entities I think that one of the
I recently asked about keyword expansion in Git and I'm willing to accept the

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.