Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

I'm creating an IRC bot and I want to be able to constantly receive from my buffer, but at the same time if I type a command into the console I want it to be readily accepted. So far I have a infinite loop that constantly checks the input buffer of the IRC server, but I don't know how I can receive input from the console without freezing everything else.

share|improve this question
3  
You need threads to do this, see stackoverflow.com/questions/31340/… – Senjai May 30 '13 at 5:14
    
Or a UI system with event handling. – Lennart Regebro May 30 '13 at 6:22

1 Answer 1

The best thing to do in this case is to use some sort of UI library that contains an event loop. You poll this event loop for things that happen including keys pressed and mouse clicks.

If you want to do this in a terminal, there is Urwid. If you want to do it as a GUI there are tons of systems available, like:

  • Gnome
  • GTK
  • KDE
  • Tcl/Tk
  • Qt4
  • Kivy

And more of them, and then loads more which aren't cross-platform.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.