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:<div>
<br></div><div><span class="Apple-style-span" style="font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 10px; line-height: 22px; white-space: nowrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><ol start="1" style="background-color: rgb(231, 229, 220); margin-top: 0px; margin-bottom: 0px; ">
<li class="codeLI" style="font-size: 12px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; font-family: &#39;Courier New&#39;, Courier, monospace; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(240, 240, 240); border-left-width: 3px; border-left-style: solid; border-left-color: green; font-weight: normal; line-height: 18px; text-indent: 5px; padding-top: 2px; padding-right: 0px; padding-bottom: 2px; padding-left: 0px; background-position: initial initial; background-repeat: initial initial; ">
def run(*args):</li><li class="codeLI" style="font-size: 12px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; font-family: &#39;Courier New&#39;, Courier, monospace; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(240, 240, 240); border-left-width: 3px; border-left-style: solid; border-left-color: green; font-weight: normal; line-height: 18px; text-indent: 5px; padding-top: 2px; padding-right: 0px; padding-bottom: 2px; padding-left: 0px; background-position: initial initial; background-repeat: initial initial; ">
    n=0;master=mainframe</li><li class="codeLI" style="font-size: 12px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; font-family: &#39;Courier New&#39;, Courier, monospace; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(240, 240, 240); border-left-width: 3px; border-left-style: solid; border-left-color: green; font-weight: normal; line-height: 18px; text-indent: 5px; padding-top: 2px; padding-right: 0px; padding-bottom: 2px; padding-left: 0px; background-position: initial initial; background-repeat: initial initial; ">
    best.set(&#39;test # %d&#39; % (n))</li><li class="codeLI" style="font-size: 12px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; font-family: &#39;Courier New&#39;, Courier, monospace; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(240, 240, 240); border-left-width: 3px; border-left-style: solid; border-left-color: green; font-weight: normal; line-height: 18px; text-indent: 5px; padding-top: 2px; padding-right: 0px; padding-bottom: 2px; padding-left: 0px; background-position: initial initial; background-repeat: initial initial; ">
    n += 1</li><li class="codeLI" style="font-size: 12px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; font-family: &#39;Courier New&#39;, Courier, monospace; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(240, 240, 240); border-left-width: 3px; border-left-style: solid; border-left-color: green; font-weight: normal; line-height: 18px; text-indent: 5px; padding-top: 2px; padding-right: 0px; padding-bottom: 2px; padding-left: 0px; background-position: initial initial; background-repeat: initial initial; ">
    if n &lt;= 10:</li><li class="codeLI" style="font-size: 12px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; font-family: &#39;Courier New&#39;, Courier, monospace; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(240, 240, 240); border-left-width: 3px; border-left-style: solid; border-left-color: green; font-weight: normal; line-height: 18px; text-indent: 5px; padding-top: 2px; padding-right: 0px; padding-bottom: 2px; padding-left: 0px; background-position: initial initial; background-repeat: initial initial; ">
        mainframe.after(1000, run, n, master)</li></ol><div style="text-indent: 5px;"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px; line-height: 18px;"><br></span></font></div>
<div style="text-indent: 5px;"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px; line-height: 18px;"><br></span></font></div></span><div class="gmail_quote"><font class="Apple-style-span" face="&#39;Courier New&#39;, Courier, monospace" size="3"><span class="Apple-style-span" style="font-size: 12px; line-height: 18px; white-space: nowrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><br>
</span></font></div><div class="gmail_quote"><font class="Apple-style-span" face="&#39;Courier New&#39;, Courier, monospace" size="3"><span class="Apple-style-span" style="font-size: 12px; line-height: 18px; white-space: nowrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><span class="Apple-style-span" style="font-family: arial; line-height: normal; white-space: normal; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; font-size: small; "><span class="Apple-style-span" style="font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 12px; line-height: 18px; white-space: nowrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">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</span></span></span></font></div>
<div class="gmail_quote"><font class="Apple-style-span" face="&#39;Courier New&#39;, Courier, monospace" size="3"><span class="Apple-style-span" style="font-size: 12px; line-height: 18px; white-space: nowrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><span class="Apple-style-span" style="font-family: arial; line-height: normal; white-space: normal; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; font-size: small; "><span class="Apple-style-span" style="font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 12px; line-height: 18px; white-space: nowrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "></span></span></span></font><span class="Apple-style-span" style="font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 12px; line-height: 18px; white-space: nowrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">algorithm itself restarts G times. Any ideas how to handle this?</span></div>
<div class="gmail_quote"><span class="Apple-style-span" style="font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 12px; line-height: 18px; white-space: nowrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><br>
</span></div><div class="gmail_quote"><span class="Apple-style-span" style="font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 12px; line-height: 18px; white-space: nowrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">Sorry for being messy, it&#39;s just the ONLY thing that I can&#39;t make work here, everything is is just fine)</span></div>
<div class="gmail_quote"><span class="Apple-style-span" style="font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 12px; line-height: 18px; white-space: nowrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><br>
</span></div><div class="gmail_quote"><span class="Apple-style-span" style="font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 12px; line-height: 18px; white-space: nowrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">thanks </span></div>
<div><font class="Apple-style-span" face="&#39;Courier New&#39;, Courier, monospace" size="3"><span class="Apple-style-span" style="font-size: 12px; line-height: 18px; white-space: nowrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><span class="Apple-style-span" style="font-family: arial; line-height: normal; white-space: normal; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; font-size: small; "><span class="Apple-style-span" style="font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 12px; line-height: 18px; white-space: nowrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><br>
</span></span></span></font></div><div class="gmail_quote">2010/8/19 Alex Ter-Sarkissov <span dir="ltr">&lt;<a href="mailto:sigma.z.1980@gmail.com">sigma.z.1980@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
thanks guys, this does seem to work...nevertheless, since I&#39;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&#39;s last example)<div>

<br></div><div><span style="color:rgb(54, 53, 49);font-family:Tahoma, Arial;font-size:13px"><pre><span style="color:rgb(0, 112, 32);font-weight:bold">def</span> <span style="color:rgb(6, 40, 126)">increment</span><span>(*args):</span>
<a name="12a87bba21e04a4e_line-15" style="text-decoration:none"></a>    <span>var</span><span style="color:rgb(102, 102, 102)">.</span><span>set</span><span>(</span><span>var</span><span style="color:rgb(102, 102, 102)">.</span><span>get</span><span>()</span><span style="color:rgb(102, 102, 102)">+</span><span style="color:rgb(64, 160, 112)">1</span><span>)</span>
<a name="12a87bba21e04a4e_line-16" style="text-decoration:none"></a>    <span>root</span><span style="color:rgb(102, 102, 102)">.</span><span>after</span><span>(</span><span style="color:rgb(64, 160, 112)">1000</span><span>,</span> <span>increment</span><span>)</span></pre>

</span></div><div><br></div><div>but1=Button(text=&quot;click me&quot;, command=increment)</div><div>but1.grid()</div><div><br></div><div>but without any success.</div><div><br></div><div>cheers!  <br><div><br></div><div>

<br><div class="gmail_quote">2010/8/19 Firat Ozgul <span dir="ltr">&lt;<a href="mailto:ozgulfirat@gmail.com" target="_blank">ozgulfirat@gmail.com</a>&gt;</span><div class="im"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

[quote]Cameron Laird: &quot;update() is *not* essential:  after() provides a non-threading alternative.&quot;[/quote]<br><br><div class="gmail_quote"><div>I agree. If you would not like to use update(), you can use after() in your code with pretty much the same functionality:<br>


 </div></div><a href="http://paste-it.net/public/e7ce371/" target="_blank">http://paste-it.net/public/e7ce371/</a><br>
</blockquote></div></div><br></div></div>
</blockquote></div><br></div>