in reply to window destroying

First, your PS image problem is obvious. You create $image fine, but you call it 'image1' in the label. It should be
-image => $image,

Second, in your main problem, I'm not sure what you are trying to do, but I am "pretty sure" you are doing it the wrong way. You are setting yourself up for "pseudo memory leaks" in trying to destroy, then create another window.

What will probably happen, if you run this code for a long period, opening then destroying windows, the memory usage of your program will just keep "going up",( a big chunk for each window you create and destroy). Tk stores alot of references to windows and widgets, and it is nearly impossible to write a Tk program which properly (and completely) destroy a window.

What you want to do, is to create 1 mainwindow, and a top-level window. Then "withdraw" them. When you want to raise them, you can do

$mw->deiconify; $mw->raise; #or $top1->deiconify; $top1->raise;
Then instead of destroying them, when you are done, just
$mw->withdraw; #or $top1->withdraw;

Now you are reusing your windows, and no matter how many times you raise and withdraw them, your memory will stay level. You can also repack the windows with different widgets, while they are withdrawn, so they can "appear to be" totally new windows.

With Tk, always design to reuse widgets. If you want to change that image, don't destroy it, just configure $image to load a different file.

Finally, having 2 MainLoops, is probably asking for trouble. You should only need a single MainLoop in any Tk program, unless you are forking.

I'm sorry if I seemed super critical of your script, but I'm just trying to save you time, because if you write 1000 lines of code, then find out it leaks memory, it will be quite disappointing. I learned "the hard way". :-)


I'm not really a human, but I play one on earth. flash japh