Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #50772

Re: tkinter redraw rates

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.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.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'represents': 0.05; 'canvas': 0.07; 'scale.': 0.07; 'tkinter': 0.07; 'events.': 0.09; 'image,': 0.09; 'logic': 0.09; 'prevents': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'whichever': 0.09; 'window.': 0.09; 'gui': 0.12; 'thread': 0.14; 'driven.': 0.16; 'function;': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'resizing': 0.16; 'scaled': 0.16; 'stuff,': 0.16; 'stuff.': 0.16; 'tasks,': 0.16; 'tkinter.': 0.16; 'wrote:': 0.18; 'app': 0.19; 'written': 0.21; 'this?': 0.23; 'header:User-Agent:1': 0.23; 'tonight': 0.24; "i've": 0.25; 'changes,': 0.26; 'second': 0.26; 'post': 0.26; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'point': 0.28; 'scale': 0.29; "doesn't": 0.30; "i'm": 0.30; 'program,': 0.31; 'usually': 0.31; 'changed.': 0.31; 'loads': 0.31; 'with,': 0.31; 'figure': 0.32; 'another': 0.32; 'guess': 0.33; 'older': 0.33; 'third': 0.33; "i'd": 0.34; 'could': 0.34; "can't": 0.35; 'but': 0.35; 'done,': 0.36; 'returning': 0.36; 'possible': 0.36; 'two': 0.37; 'performance': 0.37; 'problems': 0.38; 'window': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'fact': 0.38; 'pm,': 0.38; 'little': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'even': 0.60; 'around.': 0.60; 'chain': 0.60; 'most': 0.60; 'tell': 0.60; 'break': 0.61; 'issues,': 0.61; 'new': 0.61; "you're": 0.61; 'you.': 0.62; 'back': 0.62; 'email addr:gmail.com': 0.63; 'more': 0.64; 'fire': 0.65; 'hoping': 0.75; 'around,': 0.84; 'calls,': 0.84; 'done;': 0.84; 'forced': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dave Angel <davea@davea.name>
Subject Re: tkinter redraw rates
Date Tue, 16 Jul 2013 21:40:15 -0400
References <b80dcc82-7fdb-4213-bec0-5e704483ce28@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 <b80dcc82-7fdb-4213-bec0-5e704483ce28@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.4794.1374025243.3114.python-list@python.org> (permalink)
Lines 43
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1374025243 news.xs4all.nl 15922 [2001:888:2000:d::a6]:34748
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:50772

Show key headers only | View raw


On 07/16/2013 08:57 PM, fronagzen@gmail.com wrote:
> Hm. So I've written a GUI in tkinter. I've found two performance issues, I was hoping someone could point me in the right direction.
>
> Firstly, I'm using an image as a border, namely:

     <SNIP>
>
> This works, yes, but is annoyingly laggy on an older computer when I try to move the window around. I figure it's because the program has to keep redrawing the image border when dragged around, and is exacerbated by the fact that I have two of the imageborder frames in my application. How can I remedy this? I've tried using a hard-drawn image on a Canvas instead of the image border, but it's suboptimal because that prevents resizing the window.
>

This part I can't help with, as I'm not that familiar with tkinter in 
particular.  If I had to guess an approach, I'd tell you to create an 
object that represents the scaled border image, and then when it moves, 
you just reblit it.  And if/when the scale changes, you then recreate 
the object at the new scale.  Most of the time you won't be scaling.

But what that means in tkinter calls, I don't know and don't have time 
tonight to figure out.

>
> The other performance issue I've found is that when the logic is running, the app doesn't redraw. Ordinarily this would be acceptable, but as part of my program, it loads data from a website, and during the load, the window completely freezes up and doesn't respond until the download is done; as I understand it, tkinter doesn't redraw until it is forced to by .update() or control is given back to the mainloop. How can I force a more frequent redraw rate?
>

Tkinter, like every other GUI I know of, is event driven.  You're not 
intended to do "logic is running" kinds of events.  Break up larger 
problems into little tasks, and daisy chain them, returning to the event 
loop after each little piece.

A second approach that works with some GUI's is to fire up the event 
loop at periodic intervals in your long function;  get it to do a few 
other events and then return to you.  This isn't recommended usually 
because it can get very messy.  And it may not even be possible in tkinter.

Third approach is to start another thread to do the "logic is running." 
  Make sure that thread never calls any GUI stuff, but just updates 
values that can be seen by the main thread and its GUI stuff.  When 
you're done, post a message to the GUI to tell it to redraw whichever 
parts are now changed.


-- 
DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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