<!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>
<br>
import Numeric, time, Gnuplot<br>
<br>
def cooldown()<br>
<br>
A = Numeric.arange(-1, 1, .1)<br>
delay = 5<br>
<br>
########################################<br>
########################################<br>
<br>
X = []<br>
Y = []<br>
XY = []<br>
g = Gnuplot.Gnuplot()<br>
g('set data style linespoints') <br>
try: <br>
while A[0]<10:<br>
val1 = 1<br>
val2 = 2<br>
XY.append([val1, val2])<br>
if len(XY) > 1:<br>
g.plot(XY)<br>
except KeyboardInterrupt: # Pressing Ctrl-C will result in
ending the program but saving all the data taken so far<br>
pass <br>
return g<br>
</font><br>
<br>
<font face="Courier New, Courier, monospace"> win1 = Tk()<br>
win1.title('Control Panel')</font><br>
<font face="Courier New, Courier, monospace">RunFrame
= Frame(win1, bd = 2, relief = 'groove')<br>
RunCooldown = Button(RunFrame)<br>
RunCooldown.configure(text = 'Cooldown', fg = 'blue', command =
cooldown, cursor = 'target')<br>
RunCooldown.pack(side = LEFT)<br>
<br>
</font><br>
<br>
Thanks,<br>
<br>
Amit.<font face="Courier New, Courier, monospace"><br>
</font>
</body>
</html>