I played around a little bit: by changing forcing secondary_win to generate the phwin (your !Exists block) and by making $mw process one event, I was able to make the main window draw first and end up first in my Win7 application bar...
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
use Tk::Pane;
my $mw = new MainWindow ();
$mw->title(" $0 MAIN");
my $phwin; # deleted '= $mw->Toplevel();': force it to be created by s
+econdary_win() function
my $fr0 = $mw->Frame(-borderwidth => 2, -relief => 'groove'
)->pack();
$fr0->Label(-text => "MAIN $0 MAIN"
)->pack();
$mw->DoOneEvent(); # appears to force mw to draw itself _before_ seco
+ndary_win() creates phwin
sleep(1); # makes it obvious that there's a delay; don't use
+ in production
&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;
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|