Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

How to be always on TOP

by gerry (Sexton)
on Feb 28, 2005 at 14:55 UTC ( #435073=perlquestion: print w/ replies, xml ) Need Help??
gerry has asked for the wisdom of the Perl Monks concerning the following question:

My question pertains to how one can keep a perl/Tk appl. always on Top. For example, I have a perl/Tk module that runs continuously and monitors the health of our various Unix Servers by displaying different colored lights signifying the server/application health. (unable to make socket connection, timeout, database not avail., various files missing, ect...). Whenever, I bring up another application (such as Firefox or email, etc...) it gets overlaid. I want it to always be on top so it can be seen and never hidden. Is there a way to do this? Thanks for your help.

Comment on How to be always on TOP
Re: How to be always on TOP
by Anonymous Monk on Feb 28, 2005 at 15:01 UTC
    Probably the best way is to tell your window manager you want a particular application to be always on top. At least, that's how I would do it - I think it should be the users decision, not the application authors.
Re: How to be always on TOP
by mawe (Hermit) on Feb 28, 2005 at 15:38 UTC
      I tried using the StayOnTop.pm module, but I must be doing something wrong. I'm on Perl 5.8.0 so I assume I must use Win32::API. I downloaded API.pm into the ...\lib\Win32 directory. I also downloaded StayOnTop.pm into the ..\lib\Tk directory.

      I now have the following at the beginning of my code:

      use Tk; use Win32::API; use Tk::StayOnTop; use IO::Socket; use IO::Select;

      I updated the @INC to point to the Win32 directory. However, whenever, I attempt to run the program I keep getting the message:

      Can't locate loadable object for module Win32::API in @INC (@INC conta +ins: C:\Perl\site\lib\Win32 C:\Perl\site\lib C:\Perl\site\lib\Win32\A +PI c:/Perl/lib c:/Perl/site/lib .) at smalllights.pl line 13

      I am not sure which loadable object is causing the problem. Is it possible that I need another module?

        You may need to install the module using the ppm tool.

        Win32::API contains code that must be compiled, install it properly using CPAN.pm or the makefile.pl it comes with.
Re: How to be always on TOP
by tall_man (Parson) on Feb 28, 2005 at 15:40 UTC
    Here is a thread with useful hints, especially for Windows: "Always on top" with Win32 and Tk. You can also set an event handler for window hide events and put the window to the top that way, but watch out for two windows that do the same -- they will fight back and forth.
Re: How to be always on TOP
by zentara (Archbishop) on Mar 01, 2005 at 12:34 UTC
    You probably can use overriderediect.
    #!/usr/bin/perl use warnings; use strict; use Tk; my $mw = tkinit; $mw->geometry("200x300+200+200"); $mw->overrideredirect(1); # set the override-redirect flag $mw->Button( -text => 'Quit', -command => sub { Tk::exit(0) }, )->pack( -side => 'bottom', ); MainLoop;
    If that dosn't work, or you want to keep the window manager controls, you can set a timer, which will refresh your screen every second, and "raise" it to the top.
    #!/usr/bin/perl use Tk; use strict; use warnings; my $top = new MainWindow; keep_on_top($top); MainLoop; sub keep_on_top { my $w = shift; my $toprepeater = $w->repeat(100, sub{ $w->raise }); }

    I'm not really a human, but I play one on earth. flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://435073]
Approved by friedo
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2014-12-19 02:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (70 votes), past polls