For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > December 2006 > bringing a process to foreground.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author bringing a process to foreground.
rajendra

2006-12-15, 4:03 am

Hello All,
In one of script, I use a Perl TK to get the user login information. But by
the time, I get the TK window for login, if I change my focus to some other
process, the Perl TK window will be in background.
So I would like to know how to bring this Perl TK window to foreground.


zentara

2006-12-15, 7:03 pm

On Fri, 15 Dec 2006 13:28:22 +0530, "rajendra"
<rajendra.pra@in.bosch.com> wrote:

>Hello All,
>In one of script, I use a Perl TK to get the user login information. But by
>the time, I get the TK window for login, if I change my focus to some other
>process, the Perl TK window will be in background.
>So I would like to know how to bring this Perl TK window to foreground.
>


You could use $mw->overrideredirect(1); to make the window
grab global focus and stay on top on all virtual desktops; but that
is often too harsh, and demands immediate attention.

What you probably could do, is use a timer to keep the
window on top. When you want to cancel the stay-on-top;
cancel the $repeater

#!/usr/bin/perl
use Tk;
use strict;
use warnings;

my $top = new MainWindow;
my $repeater;

keep_on_top($top);

#cancel after 10 seconds
$top->after(10000, sub{ $repeater->cancel });

MainLoop;

sub keep_on_top {
my $w = shift;
#raise every tenth second
$toprepeater = $w->repeat(100,
sub{ $w->raise });
}
__END__




--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
Ch Lamprecht

2006-12-15, 7:03 pm

rajendra wrote:
> Hello All,
> In one of script, I use a Perl TK to get the user login information. But by
> the time, I get the TK window for login, if I change my focus to some other
> process, the Perl TK window will be in background.
> So I would like to know how to bring this Perl TK window to foreground.
>
>

Hi,

if you are on windows, you can use

$main_window->attributes(-topmost => 1);

That will work with MainWindow or Toplevel objects.

Christoph
--

perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"
aakash

2006-12-17, 4:04 am

Hello All,
When i tried to use the below command it gives me an error : "Can't call
method "attributes" on unblessed reference at ( folllowed by line no.)"

Aakash

"Ch Lamprecht" <ch.l.ngre@online.de> wrote in message
news:elv86i$co2$1@online.de...
> rajendra wrote:
by[color=darkred]
other[color=darkred]
> Hi,
>
> if you are on windows, you can use
>
> $main_window->attributes(-topmost => 1);
>
> That will work with MainWindow or Toplevel objects.
>
> Christoph
> --
>
> perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"



Ch Lamprecht

2006-12-17, 7:02 pm

aakash wrote:



> "Ch Lamprecht" <ch.l.ngre@online.de> wrote
[color=darkred]
> When i tried to use the below(above) command it gives me an error : "Can't
> call
> method "attributes" on unblessed reference at ( folllowed by line no.)"


Hi aakash,
please post a short but complete example.
Please don' top-post.

Christoph
--

perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"
rajendra

2006-12-28, 8:00 am

Hello All,
Please find my small script.

use Tk;
$main=MainWindow->new;
$main->Button(-text => "Click",-command => \&disp)->pack(-side =>'left');
$text1=$main->Text(-width => 40 ,-height => 2)->pack;
$text1->bind('<Enter>',\&disp);

MainLoop;

sub disp
{
$text1->insert('end',"Hello");
}

What should I add for this script to bring the window that gets generated by
this script to foreground even if I change my focus?..
"Ch Lamprecht" <ch.l.ngre@online.de> wrote in message
news:em41o7$odb$1@online.de...
> aakash wrote:
>
>
>
>
"Can't[color=darkred]
>
> Hi aakash,
> please post a short but complete example.
> Please don' top-post.
>
> Christoph
> --
>
> perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"



Ch Lamprecht

2006-12-28, 8:00 am

rajendra wrote:
> Hello All,
> Please find my small script.
>
> use Tk;
> $main=MainWindow->new;
> $main->Button(-text => "Click",-command => \&disp)->pack(-side =>'left');
> $text1=$main->Text(-width => 40 ,-height => 2)->pack;
> $text1->bind('<Enter>',\&disp);


$main->after(500,sub{$main->attributes(-topmost=> 1)});
# this works on windows
>
> MainLoop;
>
> sub disp
> {
> $text1->insert('end',"Hello");
> }
>
> What should I add for this script to bring the window that gets generated by
> this script to foreground even if I change my focus?..


Again: It's easier to follow the discussion if you don't top-post.

Christoph

--

perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com