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 here and got some great answers! Custom SQL GROUP
I recently asked this question https://softwareengineering.stackexchange.com/questions/129076/go-instead-of-c-c-with-cgo and got some very interesting input. However there's
I recently asked this question on here and got the answer. However I'm now
I recently asked this question and got back a great solution using jquery for
i recently asked this question and i got a lot of great answers breaking
Very recently I've asked this question, but wasn unable to fix this. So I
Further to this question and this one that I asked more recently but without
I recently asked this question , but after some of the responses and some
I recently asked this question: MS SQL share identity seed amongst tables (Many people
Recently I asked this question: Removing up to 4 spaces from a string and

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.