[Tkinter-discuss] Windows inaccessible while a module is running

Amit Finkler amit.finkler at gmail.com
Thu Mar 6 12:13:01 CET 2008


Cameron Laird wrote:
> On Wed, Mar 05, 2008 at 05:55:37PM +0100, Gigs_ wrote:
> 			.
> 			.
> 			.
>   
>>> 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?
>>>       
> 			.
> 			.
> 			.
>   
>> you will need to make thread for that function to separate execution 
>> from gui
>>     
> 			.
> 			.
> 			.
> 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.
>   
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:
   
import Numeric, time, Gnuplot

def cooldown()
   
    A             = Numeric.arange(-1, 1, .1)
    delay         = 5
   
    ########################################
    ########################################

    X  = []
    Y  = []
    XY = []
    g  = Gnuplot.Gnuplot()
    g('set data style linespoints')
    try:       
    while A[0]<10:
        val1 = 1
        val2 = 2
        XY.append([val1, val2])
        if len(XY) > 1:
            g.plot(XY)
        except KeyboardInterrupt: # Pressing Ctrl-C will result in
ending the program but saving all the data taken so far
        pass   
    return g


    win1             = Tk()
    win1.title('Control Panel')
        RunFrame               = Frame(win1, bd = 2, relief = 'groove')
    RunCooldown          = Button(RunFrame)
    RunCooldown.configure(text = 'Cooldown', fg = 'blue', command =
cooldown, cursor = 'target')
    RunCooldown.pack(side = LEFT)



Thanks,

Amit.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080306/4d1bf941/attachment.htm 


More information about the Tkinter-discuss mailing list