Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51934
| Date | 2013-08-04 20:20 +0200 |
|---|---|
| From | Vincent Vande Vyvre <vincent.vandevyvre@swing.be> |
| Subject | Re: In pyqt, some signals seems not work well |
| References | <BAY175-W414DAF53B9935BAD5F8714F3530@phx.gbl> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.187.1375640467.1251.python-list@python.org> (permalink) |
Le 04/08/2013 18:06, Jacknaruto a écrit :
> Hi, Guys!
>
> I created a thread class based QThread, and defined some signals to
> update UI through main thread.
>
> the UI used a stackedWidget,someone page named 'progressPage' have a
> progressBar and a Label, the next page named 'resultsPage' shows
> results(some Labels).
>
> When the window showed progressPage, my code that updates progressBar
> was well, but the updating resultsPage's labels signals seems ignored
> by main thread.(I guess, because I added some prints in the slot, it
> wasn't printed)
>
> the code like this:
>
> 1. class worker(QtCore.QThread):
> 2. sig_jump_finish_page = QtCore.pyqtSignal()
> 3. sig_set_label_text = QtCore.pyqtSignal(str, str)
> 4. sig_set_progress_value = QtCore.pyqtSignal(int)
> 5.
>
> 6. for dirpath, dirnames, filenames in os.walk(self.root):
> 7. for filename in filenames:
> 8. self.sig_set_label_text.emit('current', self.current()) # work well
> 9. # so something
>10.
>
> 11. #self.dialog.set_found(str(self.found())) # work well
> 12. #self.dialog.set_all(str(self.total())) # work well
> 13. self.sig_set_label_text.emit('found', str(self.found())) # :(
> 14. self.sig_set_label_text.emit('all', str(self.total())) # :(
>15.
>
> 16. self.sig_jump_finish_page.emit()
>
>
> So I have to update UI directly in the thread(comments Line 11-12
> shows), it looks work well.
>
> I found the difference between line 8 and line 13-14 is line 8
> manipulates current page -progressPage, line 13-14 manipulates next
> page -resultsPage.
>
> Is some wrongs in there?
>
>
>
>
>
Have a look at my comments:
class worker(QtCore.QThread):
sig_jump_finish_page = QtCore.pyqtSignal()
sig_set_label_text = QtCore.pyqtSignal(str, str)
sig_set_progress_value = QtCore.pyqtSignal(int)
for dirpath, dirnames, filenames in os.walk(self.root): # What is 'self'
here ?
for filename in filenames:
self.sig_set_label_text.emit('current', self.current()) # where is
'current' ?
# so something
#self.dialog.set_found(str(self.found())) # What is self, and dialog,
and found ?
#self.dialog.set_all(str(self.total())) # ...
self.sig_set_label_text.emit('found', str(self.found())) # again ?
self.sig_set_label_text.emit('all', str(self.total())) # etc
self.sig_jump_finish_page.emit()
--
Vincent V.V.
Oqapy <https://launchpad.net/oqapy> . Qarte
<https://launchpad.net/qarte> . PaQager <https://launchpad.net/paqager>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: In pyqt, some signals seems not work well Vincent Vande Vyvre <vincent.vandevyvre@swing.be> - 2013-08-04 20:20 +0200
csiph-web