but i'm curious to know where you found this information or if just comes from your tries.
Just from tries, its simpler than reading the source
How can i retrieve more infos about tkinit anyway? in the Tk source I just see: It is just a shortcut to call for a MainWindow creation?
Its one of those things monkey see, and yes its just a shortcut , its defined inside Tk.pm, just like MainLoop
sub tkinit { return MainWindow->new(@_) }
sub MainLoop
{
unless ($inMainLoop)
{
local $inMainLoop = 1;
while (Tk::MainWindow->Count)
{
DoOneEvent(0);
}
}
}
Anyway I prefere the pryrt's solution ...
Yes, parents kill children, but you don't gotta let the user kill the window so you have to recreate it, just hide/show
#!/usr/bin/perl --
use strict;
use warnings;
use Tk;
my $mw = MakeMain();
my $phwin = MakePhwin( $mw );
$mw->focus;
$mw->WidgetDump;
MainLoop;
sub MakePhwin {
my( $mw ) = @_;
my $phwin = $mw->Toplevel;
$phwin->protocol( 'WM_DELETE_WINDOW', [sub{shift->withdraw}, $phwi
+n], );
$phwin->Label(-text => "Close me hit the little x" )->pack;
return $phwin;
}
sub MakeMain {
my $mw = tkinit(@_);
$mw->Button(
-text => "Restore phwin",
-command => sub {
$_->deiconify
for grep $_->isa('Tk::Toplevel'),
$Tk::widget->toplevel->children;
},
)->pack;
$mw->update;
return $mw;
}
-
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.