Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51945
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <naruto0.1@live.cn> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:not': 0.03; 'ignored': 0.07; '__init__': 0.09; 'filename': 0.09; 'filenames': 0.09; 'filenames:': 0.09; 'guys!': 0.09; 'label,': 0.09; 'skip:# 30': 0.09; 'thread': 0.14; '16.': 0.16; 'comments:': 0.16; 'dirnames,': 0.16; 'dirpath,': 0.16; 'self.root': 0.16; 'str)': 0.16; 'there?': 0.16; 'wrote:': 0.18; 'seems': 0.21; 'header:User- Agent:1': 0.23; 'received:65.55.116': 0.24; 'text.': 0.24; 'looks': 0.24; 'class.': 0.26; 'this:': 0.26; 'updating': 0.26; 'meeting': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'sets': 0.30; "i'm": 0.30; 'work.': 0.31; 'code': 0.31; "skip:' 10": 0.31; 'dialog': 0.31; 'object.': 0.31; 'prints': 0.31; 'skip:q 20': 0.31; 'subject:some': 0.31; 'class': 0.32; 'this.': 0.32; 'created': 0.35; 'skip:s 30': 0.35; 'something': 0.35; 'etc': 0.35; 'but': 0.35; 'object,': 0.36; 'next': 0.36; 'shows': 0.36; 'hi,': 0.36; 'conditions.': 0.38; 'window': 0.38; 'to:addr:python-list': 0.38; 'skip:- 10': 0.38; 'to:addr:python.org': 0.39; 'here': 0.66; 'between': 0.67; '11.': 0.74; 'slot,': 0.84; 'sorry.': 0.91 |
| X-EIP | [Pbe2wjrsdkRLGpL81z1qk1RQzVPbqEid] |
| X-Originating-Email | [naruto0.1@live.cn] |
| Date | Mon, 5 Aug 2013 09:37:46 +0800 |
| From | Jack <naruto0.1@live.cn> |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: In pyqt, some signals seems not work well |
| References | <BAY175-W414DAF53B9935BAD5F8714F3530@phx.gbl> <51FE9B88.8090706@swing.be> |
| In-Reply-To | <51FE9B88.8090706@swing.be> |
| Content-Type | text/plain; charset="UTF-8"; format=flowed |
| Content-Transfer-Encoding | quoted-printable |
| X-OriginalArrivalTime | 05 Aug 2013 01:37:54.0411 (UTC) FILETIME=[67D1FBB0:01CE917C] |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.197.1375666744.1251.python-list@python.org> (permalink) |
| Lines | 96 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1375666745 news.xs4all.nl 15902 [2001:888:2000:d::a6]:38777 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:51945 |
Show key headers only | View raw
On 2013/8/5 2:20, Vincent Vande Vyvre wrote:
> 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)
>
I'm sorry.
In run() function the code below
> for dirpath, dirnames, filenames in os.walk(self.root): # What is
> 'self' here ?
self is current object, isn't it? self.root is a path which the
user will specify.
> for filename in filenames:
> self.sig_set_label_text.emit('current', self.current()) # where is
> 'current' ?
> # so something
self.current() is a getter, it just returns a member that shows the
path of the current work.
>
> #self.dialog.set_found(str(self.found())) # What is self, and dialog,
> and found ?
the main thread is a dialog object.
self.dialog was assigned the dialog object in the __init__ of
worker class.
self.found() is a getter also, it returns the number of meeting the
conditions. self.total() means like this.
> #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()
>
dialog.set_all() and so on just sets the widget's text.
My English is poor, I hopeyou will excuse me.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: In pyqt, some signals seems not work well Jack <naruto0.1@live.cn> - 2013-08-05 09:37 +0800
csiph-web