Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

stay-on-top property for Toplevel for Perl-Tk GUI

by Courage (Parson)
on Oct 15, 2002 at 11:41 UTC ( #205340=perlquestion: print w/ replies, xml ) Need Help??
Courage has asked for the wisdom of the Perl Monks concerning the following question:

Dear wise perlmonks!

Is it possible to create Toplevel widget for Perl-Tk GUI which will be above all other windows?

Thanks in advance,
Courage, the Cowardly Dog

Comment on stay-on-top property for Toplevel for Perl-Tk GUI
Re: stay-on-top property for Toplevel for Perl-Tk GUI
by MZSanford (Curate) on Oct 15, 2002 at 13:14 UTC
    I am assuming you are looking to make a global grab ... somthing that will not let the user switch application's, correct ? Well, i never suggest this, as if your program hangs you may well roger the user ... After the warning, take a look at the $widget->grabGlobal() method. I do suggest the grab() method, as it is local. Adding this with the general focus methods/properties should do what you want.
    from the frivolous to the serious
      No, I did not intended to have input only for my app, I was searching for a way to display a small button that will not be obscured by other applications, so a user will be able to see my button (and press it at any time) while being in another application. Something like floating button-bar.

      Courage, the Cowardly Dog

Re: stay-on-top property for Toplevel for Perl-Tk GUI
by mce (Curate) on Oct 15, 2002 at 14:02 UTC
    Hi,

    Perhaps I can lead you in the right direction.

    You can call the method geometry on all other toplevels. Than you can type to determine the coordinates from these by taking the lowest X value and the lowest Y value, and add the X size=(highest X - lowest X) and the same for the Y size.

    Than you can call the method geometry on the newly created Toplevel with these new parameters.

    In most window managers, the newly created Toplevel will than be above the older onces.

    I hope that is what you wanted

    ---------------------------
    Dr. Mark Ceulemans
    Senior Consultant
    IT Masters, Belgium

      No, I was trying to display a small button that will not be obscured by other applications, something of kind "stay-on-top"

      Courage, the Cowardly Dog

Re: stay-on-top property for Toplevel for Perl-Tk GUI
by dree (Monsignor) on Oct 15, 2002 at 14:21 UTC
    Playing with groups.google.com I understand that <<Unix window managers do not have such a "Always on top" feature. To be more precise, most Unix window managers can do something like "Always on top", but there's no X11 standard.>> (from Slaven Rezic) From Slaven, the (untested) trick is:
    $top->bind("<Visibility>" => sub { $top->raise });

    For win32, with a trick by Toby Everett, for me works this:
    use strict; use Tk; use Win32::API; my $mw = new MainWindow; use vars qw/$Button/; $mw->Frame(-width=>200, height =>25); $mw->update; Win32::API->new("user32","SetWindowPos",[qw(N N N N N N N)],'N')->Call(hex($mw->frame()),-1,0,0,0,0,3); $Button=$mw->Button(-text => "Button", -command => sub { &do_something; }) ->pack(); MainLoop; sub do_something { #sleep(10); }

    UPDATE:
    Always from Slaven Rezic, there is a trick for KDE2:

    If you're using KDE2 the you can write following ($w is your toplevel widget):
    my($wrapper) = $w->toplevel->wrapper; $w->property('set', '_NET_WM_STATE', "ATOM", 32, ["_NET_WM_STATE_STAYS_ON_TOP"], $wrapper);
    I think the _NET_WM_* stuff is also GNOME-compliant.
      Exactly what I needed!

      Thanks a lot for your kind help!
      Courage, the Cowardly Dog

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2014-09-19 11:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (135 votes), past polls