Is my threading proper ? if yes then why code is not working?
<p>I am creating an alarm clock in python using PyQt4 and in that I am using LCD display widget, which display current updating time. For that I am using threading. But I am new to it so the problem is I have no clue how to debug that thing.</p>

<p>This is my code</p>

<pre><code>import sys
from PyQt4 import QtGui, uic
import time
import os
from threading import Thread
class MyWindow(QtGui.QMainWindow):
    def __init__(self):
        super(MyWindow, self).__init__()
        uic.loadUi('AlarmClock_UI.ui', self)
        self.show()
        self.comboBox.setCurrentIndex(0)
        self.comboBox.currentIndexChanged.connect(self.getSelection)
        self.lineEdit.setText('Please select the reminder type')
        timeThread = Thread(target = self.showTime())
        timeThread.start()   


    def getSelection(self):
        if self.comboBox.currentIndex() == 1:
            self.lineEdit.setText('Select the alarm time of your choice')

        elif self.comboBox.currentIndex() == 2:
            self.lineEdit.setText('Use those dials to adjust hour and minutes')
        else:
            self.lineEdit.setText('Please select the reminder type')

    def showTime(self):        
           showTime = time.strftime('%H:%M:%S')
           self.lcdNumber.display(showTime)





if __name__ == '__main__':
    app = QtGui.QApplication(sys.argv)
    window = MyWindow() 
    sys.exit(app.exec_())
</code></pre>

<p>I tried while loop in <code>showTime()</code> function then it was not even loading GUI just running in the background.
Thanks :)</p>

<p>Qt does not support doing GUI operations in threads other than the main thread.  So when you call self.lcddisplay.display(showTime) from within the context of your spawned thread, that is an error and Qt will not work correctly.</p>

<p>As tdelaney suggested in his comment, the best way to handle this sort of thing is to use a QTimer to emit a signal at the appropriate intervals, and update your lcddisplay in the slot that signal is connected to.  </p>

<p>(if you insist on using threads, however, e.g. as a learning exercise, then your spawned thread would need to send a message to the main thread to tell the main thread to do the display update, rather than trying to do the update itself)</p>

python multithreading pyqt4 lcd