Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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

by Anonymous Monk
on Sep 20, 2016 at 17:31 UTC ( [id://1172228]=note: print w/replies, xml ) Need Help??


in reply to Tk MainWindow and another TopLevel spawn order

Weird way to write code :) you need to pass arguments to subroutines :)

This is how it works on win32

#!/usr/bin/perl -- use strict; use warnings; use Tk; my $two = tkinit(qw/ -title 2 /); ## second in taskbar my $mw = tkinit(qw/ -title 1 /); ## first in taskbar $mw->focusForce; MainLoop; __END__

Taskbar order on win32 with tk is LIFO

alt+tab order is unrelated to taskbar order

  • Comment on Re: Tk MainWindow and another TopLevel spawn order (taskbar order LIFO win32)
  • Download Code

Replies are listed 'Best First'.
Re^2: Tk MainWindow and another TopLevel spawn order (taskbar order LIFO win32)
by Discipulus (Canon) on Sep 21, 2016 at 08:47 UTC
    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.

      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://1172228]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-19 14:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found