Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Tk MainWindow and another TopLevel spawn order (taskbar order LIFO win32)

by Discipulus (Canon)
on Sep 21, 2016 at 08:47 UTC ( [id://1172288]=note: print w/replies, xml ) Need Help??


in reply to Re: Tk MainWindow and another TopLevel spawn order (taskbar order LIFO win32)
in thread Tk MainWindow and another TopLevel spawn order

Weird way to write code :)

yes I'm here to learn a better way! ;=)

Many thanks and ++put_your_name_here for the hint about LIFO order, good to know but i'm curious to know where you found this information or if just comes from your tries.

Anyway I prefere the pryrt's solution because your using tkinit is in reality creating two distinct indipendent MainWindows: they appear in LIFO order but if you close one of them the other continue to exist.

How can i retrieve more infos about tkinit anyway? in the Tk source I just see:

@EXPORT = qw(Exists Ev exit MainLoop DoOneEvent tkinit); [..] sub tkinit { return MainWindow->new(@_) }

It is just a shortcut to call for a MainWindow creation?

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.

Replies are listed 'Best First'.
Re^3: Tk MainWindow and another TopLevel spawn order (taskbar order LIFO win32)
by Anonymous Monk on Sep 21, 2016 at 09:48 UTC

    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; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1172288]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2024-04-18 15:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found