http://qs1969.pair.com?node_id=1172209

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

Hello wise cloister community,

I'm writing a Tk Perl program where i need to spawn immediately a secondary TopLevel window. I generaly use the code similar to that posted below.

All is fine BUT due to the call to the subroutine that draw the secondary windows placed before the MainLoop the secondary window is spawned before the main one and they are ordered incorrectly in the application bar of my OS.

I know the example where a button create a new TopLevel widget, but I want the secondary windows to spawn automatically at start time.

I know that the code is doing what I said it to do; how to code to do what i want?

#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Pane; my $mw = new MainWindow (); $mw->title(" $0 MAIN"); my $phwin = $mw->Toplevel(); my $fr0 = $mw->Frame(-borderwidth => 2, -relief => 'groove' )->pack(); $fr0->Label(-text => "MAIN $0 MAIN" )->pack(); &secondary_win; MainLoop; ###################################################################### +########## sub secondary_win { # window does not exists if (! Exists($phwin)) { $phwin = $mw->Toplevel(); $phwin->title("SECONDARY"); } # window Exists else { $phwin->deiconify( ) if $phwin->state() eq 'iconic'; $phwin->raise( ) if $phwin->state() eq 'withdrawn'; } my $scrolledframe = $phwin->Scrolled('Frame',-scrollbars => 'osoe' +)->pack(); my $sec_label = $scrolledframe->Label(-text=>'SECONDARY')->pack; }

Thanks in advance

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.