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

Re: Tk window to the front of all application windows

by crabbdean (Pilgrim)
on Apr 13, 2004 at 20:02 UTC ( #344839=note: print w/replies, xml ) Need Help??

in reply to Tk window to the front of all application windows

A SOLUTION: I awoke during the night recalling a method I'd seen in the Win32Util module about "always keep ontop". Its a bruteforce way of forcing your Tk Window to the front and *keeping it there* even if you maximise other windows. See the amended code below. (Note: setting the optional flag to 1 forces it ontop, setting it to 0 disables it.

The mind of a programmer never sleeps! :-)
## Insert these into main use Win32::Sound; use Win32Util; ## subroutine for dying sub dying { my ($error) = @_; if (!$error) { $error = "(none given)"; } my $text; $text .= "\n\nTARsync Error:\n\nFailed during:\n$message\n\nReason +:\n$error"; if ($poperr) { my $box = new MainWindow(-title => "TARsync failed!", -bg => 'yellow', -bd => 4, -relief => 'ridge'); $box->overrideredirect(1); my $label = $box->Label( -textvariable=> \$text, -bg=> 'yellow', )->pack(-fill=>'both', -padx => 40, ); Win32::Sound::Play('SystemExclamation'); my $ok = $box->Button(-text => "OK", -command => [ sub{$box->destroy; exit; } ] )->pack(-padx => 20, -pady => 20 ); $box->withdraw; $box->Popup; Win32Util::keep_on_top($box, 1); MainLoop; } }

The Funkster of Mirth
Programming these days takes more than a lone avenger with a compiler. - sam
RFC1149: A Standard for the Transmission of IP Datagrams on Avian Carriers

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://344839]
[Lady_Aleena]: Discipulus, it is at 2 now, but with what I am thinking about, it could go to 3. However, only 1 is needed. The second and third are optional.
[shmem]: straight list or named parameters - that depends on whether (and how many) optional arguments you have
[Discipulus]: if so a plain list is ok, imho
[Lady_Aleena]: shmem, I already have the plugin installed, just not active.
[shmem]: if you have 1 optional argument, place that at the end of the list. If you have more, go for named parameters.
[Lady_Aleena]: 1 manditory, 2 optional.
[Discipulus]: my ($need,$opta,$optb ) = @_; .. if $opta..
[shmem]: all else leads to trouble, even if the third argument depends on the existence of the second. That may become brittle.
[Discipulus]: but if have case like subname(15,undef,3 ) maybe bettere named parameters
[Lady_Aleena]: I don't want to have to do: alpha_menu($hash, undef, $type);

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (12)
As of 2017-04-27 12:19 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (506 votes). Check out past polls.