Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I have a Perl program that creates several windows with TK. The main window (Main) will spawn various windows with the command

$window1=MainWindow -> new(); ..... $window2=MainWindow -> new(); .... $window3=MainWindow -> new(); ....

Eventually I iconify the windows, but they all have the same icon (one which reads Main) so if I want to bring up window1 I have to guess which icon to bring up, and I usually guess wrong. Is there a way to tell Tk to have the icon associated with window1 read win1, and the icon associated with window2 read win2, and so on.

Thanks in advance for any tips

klee12

Edit: g0n - code tags and formatting

Replies are listed 'Best First'.
Re: naming Icons in TK
by BrowserUk (Patriarch) on Dec 15, 2007 at 07:00 UTC
Re: naming Icons in TK
by Anonymous Monk on Dec 15, 2007 at 10:24 UTC
    I'd give each window a "title", then iconify.
    #!/usr/bin/perl use warnings; use Tk; my $mw = MainWindow->new(); my $mw2 = MainWindow->new(); my $mw3 = MainWindow->new(); $mw-> title ('Win1'); $mw2-> title ('Win2'); $mw3-> title ('Win3'); my $c = $mw->Canvas(-width => 200, -height => 200); my $c2 = $mw2->Canvas(-width => 200, -height => 200); my $c3 = $mw3->Canvas(-width => 200, -height => 200); $c->pack; MainLoop;
Re: naming Icons in TK
by Anonymous Monk on Dec 15, 2007 at 22:37 UTC
    Thanks to all who replied. I got it working. I looked for documentation, but couldn't find it; I probably should have looked more. klee12