[PyQt] Main UI stuck when ping sub thread running
不坏阿峰
onlydebian at gmail.com
Thu Jun 26 03:18:05 BST 2014
thanks both of you , David & Glenn. you are so kind man. i have use
Qthread , Signal and slot to solve it.
thanks to your help on my beginning of Python learning.
2014-06-26 4:17 GMT+07:00 Glenn Ramsey <gr at componic.co.nz>:
> Hi,
>
> It looks like your main thread waits because you are calling join() on the
> worker thread. I suggest you look up the docs for thread.join to see what
> that does.
>
> Glenn
>
>
> On 25/06/14 04:51, 不坏阿峰 wrote:
>
>> any person can help?
>>
>>
>> 2014-06-23 20:05 GMT+07:00 不坏阿峰 <onlydebian at gmail.com
>> <mailto:onlydebian at gmail.com>>:
>>
>>
>> i want to make a tools to diagnosis network. but my Main UI will
>> stuck when
>> ping is running before finish. All i want is that when the sub
>> thread is
>> running, Main UI can use and go to other tab and can do other
>> function.
>>
>> pls help me . many thanks
>>
>> ###########
>> from mychart_ui import Ui_Form
>> import verbose_ping01
>> import threading
>>
>> class MyThread(threading.Thread):
>> def __init__(self, func, args, name=''):
>> threading.Thread.__init__(self)
>> self.name <http://self.name> = name
>>
>> self.func = func
>> self.args = args
>>
>> def run(self):
>> self.res = apply(self.func, self.args)
>>
>> def getRes(self):
>> return self.res
>> def myping(host):
>> result = verbose_ping01.verbose_ping(host, count=500)
>> return result
>>
>> class myWidget(QtGui.QWidget, Ui_Form):
>> def __init__(self,parent=None):
>> QtGui.QWidget.__init__(self, parent)
>> self.setupUi(self)
>> self.pushButton.clicked.connect(self.draw)
>> self.pushButton_ping.clicked.connect(self.doping)
>>
>> def draw(self):
>> print '='
>> sc = MyStaticMplCanvas(self.matwidget, width=2, height=3,
>> dpi=100)
>> sc.show()
>> def doping(self):
>> thisthread = MyThread(myping,("192.168.123.50",))
>> thisthread.start()
>> thisthread.join()
>> time.sleep(0.5)
>> self.pingresult = thisthread.getRes()
>> newtext = "\n".join(self.pingresult)
>> self.pTE_pingresult.setPlainText(newtext)
>>
>> qApp = QtGui.QApplication(sys.argv)
>> aw = myWidget()
>> aw.show()
>> sys.exit(qApp.exec_())
>>
>>
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140626/73a151d7/attachment-0001.html>
More information about the PyQt
mailing list