[Tkinter-discuss] Forcing a window to update with while loop running

Adam Kadzban mightyshortadam at gmail.com
Thu Jun 18 22:58:36 CEST 2009


Thanks Cameron.  I realize actually having something that works is good,
however the "...do stuff..." in my code is controlling an xray beam taking
pictures on a CCD, so I want it to be as streamlined as possible.  I'll dig
through that wiki article though, and maybe take a look at threads.

Thanks again,
Adam


On Thu, Jun 18, 2009 at 3:47 PM, Cameron Laird <Cameron at phaseit.net> wrote:

> On Thu, Jun 18, 2009 at 03:34:38PM -0500, Adam Kadzban wrote:
>                        .
>                        .
>                        .
> > Hi again, let me start off by saying that my code does what I want it to,
> > it's just done in a terribly hackish way, and I'm wondering if there's a
> > better way to do it.
> >
>                         .
>                        .
>                         .
> > ...
> > loop = 1
> > ...
> > (create a button that sets loop to 0)
> > ...
> > top.update()
> > ...
> > while loop:
> >   top.update()
> >   ...do stuff...
> >   top.update()
> >
> > This works, but I feel like there's got to be a better way to be doing
> > this.  I can get rid of  the first top.update(), and one of the updates
> in
> > the loop, but this configuration seems to be the most responsive.  And
> using
> > update_idletasks() doesn't seem to work, at all.
> >
> > Anyone have an idea?
>                         .
>                        .
>                        .
> A.  A lot of people through the years have used update().
>    If you have something already working as you want ...
>    well, there's *considerable* value in that.
> B.  The idiomatic way to do such things in Tkinter is with
>    after() <URL: http://wiki.tcl.tk/1526 >.
> C.  Many programmers also use Python threads to achieve
>    the effect you describe.  I don't have an example at
>    hand just now.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20090618/f4c06ab4/attachment.htm>


More information about the Tkinter-discuss mailing list