Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #50813
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'programmer': 0.03; 'handler': 0.05; 'duplicate': 0.07; 'tkinter': 0.07; 'wednesday,': 0.07; '"__main__":': 0.09; '__name__': 0.09; 'indeed,': 0.09; 'method,': 0.09; 'output,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.12; 'gui': 0.12; 'thread': 0.14; 'blocking': 0.16; 'clear.': 0.16; 'doing,': 0.16; 'elsewhere.': 0.16; 'handler,': 0.16; 'invoked,': 0.16; 'loop.': 0.16; 'loops': 0.16; 'occurred.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'status.': 0.16; 'thread,': 0.16; 'threads.': 0.16; 'unsafe': 0.16; 'written.': 0.16; 'thursday,': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'bit': 0.19; 'app': 0.19; 'work,': 0.20; 'seems': 0.21; '>>>': 0.22; 'handles': 0.22; 'separate': 0.22; 'header:User-Agent:1': 0.23; 'large,': 0.24; 'rapidly': 0.24; 'first,': 0.26; 'this:': 0.26; 'updating': 0.26; 'second': 0.26; 'post': 0.26; 'somewhere': 0.26; 'defined': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; "doesn't": 0.30; 'besides': 0.30; "i'm": 0.30; 'that.': 0.31; '>>>>': 0.31; 'app.': 0.31; 'noted': 0.31; 'class': 0.32; 'probably': 0.32; 'figure': 0.32; 'supposed': 0.32; 'quite': 0.32; 'text': 0.33; 'says': 0.33; 'skip:_ 10': 0.34; "can't": 0.35; 'advice': 0.35; 'knows': 0.35; 'something': 0.35; 'done.': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'done,': 0.36; 'doing': 0.36; 'method': 0.36; "i'll": 0.36; 'should': 0.36; 'too': 0.37; 'being': 0.38; 'displays': 0.38; 'window': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'dave': 0.60; 'is.': 0.60; 'till': 0.61; 'new': 0.61; 'entire': 0.61; "you're": 0.61; "you'll": 0.62; "you've": 0.63; 'email addr:gmail.com': 0.63; 'july': 0.63; 'finish': 0.65; 'periodically': 0.68; 'different.': 0.84; 'fragment': 0.84; 'presumably': 0.84; 'angel': 0.91; '2013': 0.98 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Dave Angel <davea@davea.name> |
| Subject | Re: tkinter redraw rates |
| Date | Wed, 17 Jul 2013 21:07:24 -0400 |
| References | <b80dcc82-7fdb-4213-bec0-5e704483ce28@googlegroups.com> <mailman.4794.1374025243.3114.python-list@python.org> <17c2ef71-ee2d-4229-9731-e0d54a0997cb@googlegroups.com> <mailman.4795.1374027719.3114.python-list@python.org> <a3e5a3bc-248b-4f87-b161-596c6fe77fba@googlegroups.com> <mailman.4799.1374055664.3114.python-list@python.org> <ca274116-be7a-4eda-8e96-a47dd80966c1@googlegroups.com> <mailman.4801.1374061383.3114.python-list@python.org> <f564a889-99f0-4e9c-841f-830356743252@googlegroups.com> <mailman.4805.1374082807.3114.python-list@python.org> <78c6218b-2da8-41a0-9eb3-5432093b3f6b@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | 174.32.174.30 |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 |
| In-Reply-To | <78c6218b-2da8-41a0-9eb3-5432093b3f6b@googlegroups.com> |
| 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.4818.1374109662.3114.python-list@python.org> (permalink) |
| Lines | 91 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1374109662 news.xs4all.nl 15917 [2001:888:2000:d::a6]:56851 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:50813 |
Show key headers only | View raw
On 07/17/2013 08:44 PM, fronagzen@gmail.com wrote:
> On Thursday, July 18, 2013 1:38:34 AM UTC+8, Dave Angel wrote:
>> On 07/17/2013 09:18 AM, fronagzen@gmail.com wrote:
>>> On Wednesday, July 17, 2013 7:42:45 PM UTC+8, Dave Angel wrote:
>>>> On 07/17/2013 07:10 AM, fronagzen@gmail.com wrote:
>>>>> On Wednesday, July 17, 2013 6:07:22 PM UTC+8, Dave Angel wrote:
>>>>>> On 07/16/2013 11:04 PM, fronagzen@gmail.com wrote:
>>>>>>> Noted on the quoting thing.
>>>>>>> Regarding the threading, well, first, I'm not so much a programmer as someone who knows a bit of how to program.
>>>>>>> And it seems that the only way to update a tkinter window is to use the .update() method, which is what I was experimenting with. Start up a new thread that just loops the .update() with a 1ms sleep until the download is done. It seems to work, actually.
>>>>>> update() is to be used when it's too awkward to return to mainloop. In
>>>>>> my second approach, you would periodically call it inside the processing
>>>>>> loop. But unless tkinter is unique among GUI's, it's unsafe to do that
>>>>>> in any thread besides the GUI thread.
>>>>>> DaveA
>>
>>>>> Yes, based on advice from this thread, I'm doing that. From my main thread, I create a thread that handles the download while updating a variable that the mainloop displays as a text output, and in that mainloop, I have a while loop that updates the GUI until the downloading is done.
>>>> I can't figure out what you're really doing, since each message from you
>>>> says something different. You don't need a separate while loop, since
>>>> that's exactly what app.mainloop() is.
>>>> --
>>>>
>>>> DaveA
>>>
>>> Hm. My apologies for not being very clear. What I'm doing is this:
>>> self.loader_thread = Thread(target=self.loadpages,
>>> name="loader_thread")
>>> self.loader_thread.start()
>>> while self.loader_thread.isAlive():
>>> self.root_window.update()
>>> sleep(0.05)
>>> Where loadpages is a function defined elsewhere.
>>
>> Presumably this fragment is from a method of some class you've written.
>> Is it an event handler, or is this happening before you finish setting
>> up the GUI? Somewhere at top-level, you're supposed to fall into a call
>> to mainloop(), which doesn't return till the user cancels the app.
>> --
>>
>> DaveA
> This is, indeed, an event handler from a class for my GUI. My entire GUI is a bit large, so I'll not copy the entire thing here, but it roughly goes:
>
> class GUI(object):
> def __init__(self):
> [stuff]
>
> def init_button(self):
> self.execute = ttk.Button(self.input_frame, text='Tally',
> command=self.execute_now)
> self.execute.grid(column=1, row=2, sticky=(N, S, E, W), columnspan=4)
>
> def execute_now(self):
> [stuff]
> self.loader_thread = Thread(target=self.loadpages,
> name="loader_thread")
> self.loader_thread.start()
self.root_window.after(100, self.test_thread)
return
> while self.loader_thread.isAlive():
> self.root_window.update()
Nope - don't use that. Instead, post an event on the queue, and return
to the mainloop() from whence we came.
def test_thread(self):
if self.loader_thread.isAlive():
self.root_window.after(100, self.test_thread)
return
[morestuff]
> sleep(0.05)
> [morestuff]
>
> if __name__ == "__main__":
> APP = GUI()
> APP.root_window.mainloop()
>
I probably don't have it quite right, but hopefully you'll get the idea.
self.test_thread() is now a new event that will get repeatedly
invoked, to do the check on the thread status. It returns rapidly
unless the condition has occurred.
There are other things that should be done, like blocking the specific
events that would create duplicate threads.
--
DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
tkinter redraw rates fronagzen@gmail.com - 2013-07-16 17:57 -0700
Re: tkinter redraw rates David Hutto <dwightdhutto@gmail.com> - 2013-07-16 21:32 -0400
Re: tkinter redraw rates David Hutto <dwightdhutto@gmail.com> - 2013-07-16 21:34 -0400
Re: tkinter redraw rates Dave Angel <davea@davea.name> - 2013-07-16 21:40 -0400
Re: tkinter redraw rates fronagzen@gmail.com - 2013-07-16 18:51 -0700
Re: tkinter redraw rates Dave Angel <davea@davea.name> - 2013-07-16 22:21 -0400
Re: tkinter redraw rates fronagzen@gmail.com - 2013-07-16 20:04 -0700
Re: tkinter redraw rates Dave Angel <davea@davea.name> - 2013-07-17 06:07 -0400
Re: tkinter redraw rates fronagzen@gmail.com - 2013-07-17 04:08 -0700
Re: tkinter redraw rates Michael Torrie <torriem@gmail.com> - 2013-07-17 16:53 -0600
Re: tkinter redraw rates fronagzen@gmail.com - 2013-07-17 04:10 -0700
Re: tkinter redraw rates Dave Angel <davea@davea.name> - 2013-07-17 07:42 -0400
Re: tkinter redraw rates fronagzen@gmail.com - 2013-07-17 06:18 -0700
Re: tkinter redraw rates Dave Angel <davea@davea.name> - 2013-07-17 13:38 -0400
Re: tkinter redraw rates fronagzen@gmail.com - 2013-07-17 17:44 -0700
Re: tkinter redraw rates Dave Angel <davea@davea.name> - 2013-07-17 21:07 -0400
Re: tkinter redraw rates fronagzen@gmail.com - 2013-07-17 21:38 -0700
Re: tkinter redraw rates Dave Angel <davea@davea.name> - 2013-07-18 00:52 -0400
Re: tkinter redraw rates Christian Gollwitzer <auriocus@gmx.de> - 2013-07-18 09:20 +0200
Re: tkinter redraw rates fronagzen@gmail.com - 2013-07-18 02:10 -0700
Re: tkinter redraw rates Peter Otten <__peter__@web.de> - 2013-07-17 20:10 +0200
csiph-web