in reply to Starting another Tk GUI MainLoop
But if you need to use both GUI's while #2 is on the screen, then you'll want a modified version of #2 that has everything except the Mainloop call. If all the widget creation stuff is not already in a sub, just wrap it all in a sub. Put "1;" at the end of the script.
Then, add the appropriate "require" statement to the #1 script, and the button in GUI #1 that brings up #2 just has to call the one sub that creates all the widgets (including #2's mainwindow). Oh, and if #2 has a button that invokes "exit", change that to just destroy #2's mainwindow, so that #1 doesn't get shut down as well.
update: one last point to consider: if you've been good, and already have "use strict" in both scripts and are not mucking around with global variables, then folding the scripts together this way into a single program should work out just fine. But if you haven't been good, this exercise may very well educate you in the wisdom of stricture. (I know that with Tk scripts, it can be hard to avoid the use of globals in many situations. But it can be done.)
(one more update: If you happen to be using any unix-like OS, you could have both GUI's running as separate programs and both responding to user input, by passing the #2 command line string to "system()" with an ampersand at the end of the line, to run that program in the background -- e.g. system( "gui2 arg1 arg2 &" );. I'm not a windows user, so I don't know if this works for windows, but maybe it does, or maybe there's something for windows that is equivalent to running a background job. This could also mean that every time you push that button in #1, you start another #2 window running -- you could have any number of secondary GUI's going on at once, which might be very good, or very bad, depending...)
|
|---|