Tkinter: different results from the same tcl script

Fabrizio Pollastri pollastri at iriti.cnr.it
Tue Jun 26 04:06:16 EDT 2007


Hello,
in mixed python-tcl programming I found the following different 
behaviours of the same tcl script.

If I type manually in the python interpreter the following lines

 >>> from Tkinter import *
 >>> w = Tk()
 >>> w.tk.evalfile('my_tcl_script.tcl')

where my_tcl_script.tcl is

    #!/bin/sh
    package require Tk
    wm withdraw .
    toplevel .root
    wm title .root "My title"

I obtain one toplevel window with title "My title", as expected.


The same result is obtained with the tcl shell command

% wish my_tcl_script.tcl


Now, I wish to run the same instructions from a python script. So, I 
written the following script

    from time import *
    from Tkinter import *
    w = Tk()
    w.tk.evalfile('my_tcl_script.tcl')
    sleep(3)

I expected to see the same toplevel window for 3 seconds, but the result 
of this python script is nothing, no window appears.

If anybody can explain the different behaviour and how to normalize it 
with the correct one, I will be very glad. Thank you in advance.


F. Pollastri



More information about the Python-list mailing list