Background Timer in PyQt Python Applicatiion
<p>I am Building an application in python using PyQt4. I want to add a background timer to my application so that when the timer runs out, the text editor in my application stops receiving input and freezes up.
I have tried the following method so far:</p>

<pre><code>def main():
    app = QtGui.QApplication(sys.argv)
    main = Main()
    main.show()  
    start = time.time()
    #this loop is for the time interval within which the text area of
    #the editor will accept inputs.   
    while time.time() - start &lt; 120:
        pass
    #this will set the text area to a read only state after and will not
    #any more inputs.    
    main.text.setReadOnly(True)
    sys.exit(app.exec_())
</code></pre>

<p>But whenever I run this the application stops responding. I have also tried running the timer through a thread but in that case also the application stops responding.</p>

<p>How can I implement this functionality?</p>

<p>P.S. - I am a Beginner in PyQt.</p>

<pre><code>class Main(QtGui.QMainWindow):
    def __init__(self,parent = None):
        QtGui.QMainWindow.__init__(self,parent)
        self.init_ui()

    def init_ui(self):
        self.text = QtGui.QTextEdit(self)
        self.setCentralWidget(self.text)
        self.statusbar = self.statusBar()        
        self.setGeometry(100,100,1080,720)
        self.setWindowTitle("Text Editor")
</code></pre>

<p>This is the watered down version of the main class code. Hope this helps.</p>