[Tkinter-discuss] update of elements in GUI
Alex Ter-Sarkissov
sigma.z.1980 at gmail.com
Thu Aug 19 05:44:11 CEST 2010
Ok, it actually seems to work, apart from one thing: what if I need to
update an array, rather than a single element? I mean, each iteration I
store an array, then use it the next iteration (naturally, the first array
is generated randomly). This worked for the counter:
1. def run(*args):
2. n=0;master=mainframe
3. best.set('test # %d' % (n))
4. n += 1
5. if n <= 10:
6. mainframe.after(1000, run, n, master)
but when I do the same for a matrix, I get the computer either hung or some
errors. Ususally, I run a loop for G generations within the function, but in
this example the
algorithm itself restarts G times. Any ideas how to handle this?
Sorry for being messy, it's just the ONLY thing that I can't make work here,
everything is is just fine)
thanks
2010/8/19 Alex Ter-Sarkissov <sigma.z.1980 at gmail.com>
> thanks guys, this does seem to work...nevertheless, since I'm quite new to
> both python and gui design, one more question: how would I do the same, but
> launching the counter at the click of the button? I tried (from Firat's last
> example)
>
> def increment(*args): var.set(var.get()+1) root.after(1000, increment)
>
>
> but1=Button(text="click me", command=increment)
> but1.grid()
>
> but without any success.
>
> cheers!
>
>
> 2010/8/19 Firat Ozgul <ozgulfirat at gmail.com>
>
> [quote]Cameron Laird: "update() is *not* essential: after() provides a
>> non-threading alternative."[/quote]
>>
>> I agree. If you would not like to use update(), you can use after() in
>> your code with pretty much the same functionality:
>>
>> http://paste-it.net/public/e7ce371/
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20100819/49ef5499/attachment-0001.html>
More information about the Tkinter-discuss
mailing list