User Control Panel
Advertisements

HELP US, HELP YOU!

Perl/Tk Blinking Window

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Perl
View unanswered posts
Author Message
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Mon May 29, 2006 5:42 pm    Post subject: Perl/Tk Blinking Window Reply with quote

A while back, Matt Austin and some other guys from this forum were making an MSN Messenger client using Perl/Tk... I don't know if they're still doing that or not, but this could be interesting nonetheless:

I've discovered a possible start to a solution for making PerlTk windows flash on the task bar (like IM windows do when you receive a message and the window isn't in focus).

I found that if you call deiconify on a non-minimized window, while it doesn't have focus (nor does any window related to it)... its taskbar entry will flash.

However, if another window related to it has the focus (i.e. another Tk window from the same Perl process, or the command-prompt window running the process)... then deiconify just brings the window to your focus.

Here's an example script to illustrate this:

Code:
#!/usr/bin/perl -w

use Tk;

my $main = MainWindow->new (
    -title => '### MAIN WINDOW ###',
);
$main->geometry ('300x300');

my $timer = 10;

$main->Label (
    -textvariable => \$timer,
)->pack;

my $uno = $main->Toplevel (
    -title => 'Child One',
);
$uno->geometry ('300x100');

my $dos = $main->Toplevel (
    -title => 'Child Two',
);
$dos->geometry ('300x100');

# And go
my $stage = 1;
my $t = time();
while (1) {
    select (undef, undef, undef, 0.1);
    $main->update;

    if (time() > $t) {
        $t = time();
        $timer--;

        if ($timer == 0) {
            if ($stage == 1) {
                $uno->deiconify;
                $stage = 2;
            }
            else {
                $dos->deiconify;
                $stage = 1;
            }
            $timer = 5;
        }
    }
}


The main window will count down from 10 and then deiconify child one, then in 5 second intervals from there it will deiconify the opposite child window. If you leave the focus on one of this script's Tk windows, the deiconify call brings the window in question to your focus. If you have another window active (i.e. Firefox or Notepad), then the deiconified window will blink on the task bar on Windows.

This might be a start in the right direction for how to make windows blink for a PerlTk IM client though.

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
mattaustin
Sentinel
Sentinel


Joined: 19 Jul 2004
Posts: 556
Location: Los Angeles, CA
Reputation: 50.7
votes: 1

PostPosted: Mon May 29, 2006 9:48 pm    Post subject: Reply with quote

That's a really good find. I have seen a few apps that use this to not be annoy by taking focus.. but still get you attention.
_________________
[ matt ]
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Perl All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group