import sys
import threading
import time

from PyQt4 import QtCore, QtGui

class Shell(threading.Thread):

    TIMEOUT = 100

    def __init__(self):
        threading.Thread.__init__(self)
        self.timer = QtCore.QTimer()
        QtCore.QObject.connect(self.timer,
                               QtCore.SIGNAL( 'timeout()' ),
                               self.on_timer)

    def run(self):
        while 1:
            try:
                raw_input('tell me something:\n\n')
#                time.sleep(0.1)
#                print 0
            except KeyboardInterrupt:
                break
            except EOFError:
                break
        QtGui.qApp.exit()

    def mainloop(self):
        if QtGui.QApplication.startingUp():
            a = QtGui.QApplication(sys.argv)
        self.timer.start( self.TIMEOUT )
        self.start()
        QtGui.qApp.exec_()
        self.join()

    def on_timer(self):
        print 1

test = Shell()
test.mainloop()
