[Tkinter-discuss] update of elements in GUI

Firat Ozgul ozgulfirat at gmail.com
Wed Aug 18 07:19:38 CEST 2010


If I am not mistaken you want something like this:

1) http://paste-it.net/public/i2de44d/ (with threads and classes)

2) http://paste-it.net/public/f5e340e/ (without threads and classes)

Note that without threads, we need to use the update() method. However,
without threads you will experience some degree of "blockage" in the
application anyway.


2010/8/18 Alex Ter-Sarkissov <sigma.z.1980 at gmail.com>

> thanks, in one of these articles it says. 'Be careful - Tkinter in not
> re-entrant'. MAybe this is the problem? So far I've tried
>
>
> (1) Label(mainframe.update_idletasks(),textvariable=best,bg='#321000',fg='#000fff000',font=("Helvetica",x1)).grid(column=1,row=1)
>
> and
>
> (2)
> mainframe = Frame(root)
> mainframe.grid(column=1000, row=1000, sticky=(N, W, E, S))
> mainframe.columnconfigure(0, weight=1)
> mainframe.rowconfigure(0, weight=1)
> mainframe.update()
>
> Neither worked, of course, otherwise I woudln't be posting it)
>
> I'm not using any classes
>
> 2010/8/18 Cameron Laird <Cameron at phaseit.net>
>
>> On Wed, Aug 18, 2010 at 12:50:38AM +1200, Alex Ter-Sarkissov wrote:
>>                        .
>>                        .
>>                        .
>> > I have some elements on the screen (Labels, most importantly) which
>> content
>> > has to be updated every iteration of the algorithm run, e.g. "Iteration
>> ="
>> > [i] for i in range(n). I've tried using mainframe.update_idletasks()
>> > and
>> Label(mainframe.update_ideltasks(),textvariable=var).grid(column=1,row=1),
>> > but without success so far. In MATLAB this command is drawnow.
>>                         .
>>                        .
>>                        .
>> I believe I understand your description.
>>
>> For a "quick fix", I recommend you experiment with update() (as
>> opposed to update_idletasks()) applied to mainframe.
>>
>> For better long-term maintainability, though, you almost
>> certainly should "return to the event loop" on each iteration
>> of your run (there are also multi-threading approaches, but
>> they're somewhat trickier to code correctly).
>>
>> You might find <URL: http://wiki.tcl.tk/1255 >, <URL:
>> http://wiki.tcl.tk/1526 >, and <URL:
>> http://osdir.com/ml/python.tkinter/2008-05/msg00014.html > of
>> interest.
>>
>
>
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20100818/2f291051/attachment-0001.html>


More information about the Tkinter-discuss mailing list