<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Cameron Laird wrote:
<blockquote cite="mid20080305175029.GA14239@lairds.us" type="cite">
  <pre wrap="">On Wed, Mar 05, 2008 at 05:55:37PM +0100, Gigs_ wrote:
                        .
                        .
                        .
  </pre>
  <blockquote type="cite">
    <blockquote type="cite">
      <pre wrap="">I wrote a simple GUI with tkinter which executes a function when
pressing a button. When I press the button, the function indeed executes
starts running itself (it's a loop which draws a graph using gnuplot).
As long as the loop is running, I can't access the GUI - it's grayed
out. Only when I break the loop can I properly see the GUI back again.


Is this something you're familiar with or did I define the GUI improperly?
      </pre>
    </blockquote>
  </blockquote>
  <pre wrap=""><!---->                        .
                        .
                        .
  </pre>
  <blockquote type="cite">
    <pre wrap="">you will need to make thread for that function to separate execution 
from gui
    </pre>
  </blockquote>
  <pre wrap=""><!---->                        .
                        .
                        .
Coding with threads certainly is one common approach.  As
the e-mail I just sent hints, it's not the only one--and
sometimes not the best.
  </pre>
</blockquote>
Cameron, is it possible to give a more tkinter-specific hint, i.e. in
the tkinter syntax? I started reading through the link you mentioned
but the syntax looks more like core Tk/Tcl. In other words, how do I
make a thread (or an equivalent solution) for a function in
tkinter-python? Let's say that the code looks like the following sample:<font
 face="Courier New, Courier, monospace"><br>
&nbsp;&nbsp;&nbsp; <br>
import Numeric, time, Gnuplot<br>
<br>
def cooldown()<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = Numeric.arange(-1, 1, .1)<br>
&nbsp;&nbsp;&nbsp; delay&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 5<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; ########################################<br>
&nbsp;&nbsp;&nbsp; ########################################<br>
<br>
&nbsp;&nbsp;&nbsp; X&nbsp; = []<br>
&nbsp;&nbsp;&nbsp; Y&nbsp; = []<br>
&nbsp;&nbsp;&nbsp; XY = []<br>
&nbsp;&nbsp;&nbsp; g&nbsp; = Gnuplot.Gnuplot()<br>
&nbsp;&nbsp;&nbsp; g('set data style linespoints') <br>
&nbsp;&nbsp;&nbsp; try:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; while A[0]&lt;10:<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; val1 = 1<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; val2 = 2<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; XY.append([val1, val2])<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if len(XY) &gt; 1:<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g.plot(XY)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; except KeyboardInterrupt: # Pressing Ctrl-C will result in
ending the program but saving all the data taken so far<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pass&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; return g<br>
</font><br>
<br>
<font face="Courier New, Courier, monospace">&nbsp;&nbsp;&nbsp; win1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = Tk()<br>
&nbsp;&nbsp;&nbsp; win1.title('Control Panel')</font><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <font face="Courier New, Courier, monospace">RunFrame&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp; = Frame(win1, bd = 2, relief = 'groove')<br>
&nbsp;&nbsp;&nbsp; RunCooldown&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = Button(RunFrame)<br>
&nbsp;&nbsp;&nbsp; RunCooldown.configure(text = 'Cooldown', fg = 'blue', command =
cooldown, cursor = 'target')<br>
&nbsp;&nbsp;&nbsp; RunCooldown.pack(side = LEFT)<br>
<br>
</font><br>
<br>
Thanks,<br>
<br>
Amit.<font face="Courier New, Courier, monospace"><br>
</font>
</body>
</html>