Solution to IDLE and Tkinter troubles

Jesse W jessw at loop.com
Sat Jul 8 11:27:00 EDT 2000


Dear Python Community,
	I have noticed, as have many others, that IDLE has trouble running 
Tkinter programs.  I suspected, and read in newsgroup postings, the 
explanation that IDLE uses Tkinter and it causes problems when one 
Tkinter session is run within another.
	I have thought up, and implemented, a very simple solution to this 
problem(the code is below); however, it is pretty ugly and clumsy.  
My solution is just to use the os.system command to call python.exe 
and run the script.
	There are a few problems, however.  os.system takes a _long_ time to 
get the interpreter running and blanks my screen while it does it.  
It would be nice if there was some more efficient command to start 
the interpreter.  A second problem is the kludge randomly breaks, and 
I don't know why because I don't understand the IDLE code.  Also, 
because of my lack of IDLE knowledge, I am probably using the wrong 
calls to get what I want and I am sure it could be made cleaner.	I 
have had this for a while, and I did not post because I was sure that 
something this obvious would have already been done, or at least 
thought of as a TODO.  I still suspect I am missing something, 
because this seems so simple, and it is definitely a problem...

					Thank you for your time,
							Jesse Weinstein

My Solution:  (insert in ScriptBinding.py)
The lines with #JW after them are the lines I added

menudefs = [
        ('edit', [None,
                  ('Import module', '<<import-module>>'),
                  ('Run script', '<<run-script>>'),  
                  ('Alt Run script', '<<run-script2>>'), #JW
                 ]
        ),
    ]

def run_script2_event(self, event): #JW
        filename = self.getfilename() #JW
        if not filename: #JW
            return #JW
        print filename #JW
        os.system("c:\\python\\python.exe " + filename) #JW




More information about the Python-list mailing list