[Tutor] Python tkinter. Opening another script from main window stop main window from functioning. Looking for Help
Alan Gauld
alan.gauld at btinternet.com
Sun Apr 26 14:11:20 CEST 2015
On 26/04/15 04:23, Spencer For Friends wrote:
> I'm using a tkinter window with a button on it to open another Python
> script. When the button is clicked and the new script loads it opens up
> it's own window over top of my tkinter window. The problem is, when I
> switch back to my tkinter window, none of the buttons are click-able
> anymore. The whole windows is unresponsive.
Steven has explained that this is due to using execfile().
You should virtually never use execfile(). There is nearly
always a better way of doing whatever you want to do.
Since in this case the second script seems to be a Tkinter
program in its own right, it probably has functions that
you can call from your code if you import it as a module.
You might be able to create a new TopLevel window and in itys
constructor call those functions or set them up as callbacks
on your window. That would be the normal procedure from a GUI.
If you can't do that because the other script is badly written
(or if it were not a Python script) then you would be better
launching it as a separate process using the subprocess module.
Without knowing more about the exact structure of your code
and what you are trying to do we can't really say more than
that.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list