How do I use flash() 
Author Message
 How do I use flash()

Hi all, newbie question here, I have a listener that monitors tcp and spawns
off a button to notify person at the console of an new incoming message. I
would like the button to flash on and off continuously when it pops up. I am
using the following code:

use strict;
use Tk;
my $messagetime=localtime();
my $mw=MainWindow->new(-title=>'NEW MESSAGE',-bg=>'blue');

my $text=$mw->Button(
-bd=>10,
-relief=>'ridge',
-state=>'active',
-fg=>'green',
-bg=>'blue',
-activebackground=>'red',
-activeforeground=>'white',
-text=>$messagetime,
command=>sub{exit},
-highlightthickness=>10,
)->pack;
$text->flash();
MainLoop;

This creates the button that I want, but it doesn't flash. This is using the
Activestate Windows flavor of Perl. Am I  using flash() correctly or am I
misinterpreting the documentation about the use and function of flash()??

Thanks
Phil Sheridan



Tue, 24 Jun 2003 08:08:40 GMT  
 How do I use flash()

Quote:
> Hi all, newbie question here, I have a listener that monitors tcp and spawns
> off a button to notify person at the console of an new incoming message. I
> would like the button to flash on and off continuously when it pops up. I am
> using the following code:

> use strict;
> use Tk;
> my $messagetime=localtime();
> my $mw=MainWindow->new(-title=>'NEW MESSAGE',-bg=>'blue');

> my $text=$mw->Button(
> -bd=>10,
> -relief=>'ridge',
> -state=>'active',
> -fg=>'green',
> -bg=>'blue',
> -activebackground=>'red',
> -activeforeground=>'white',
> -text=>$messagetime,
> command=>sub{exit},
> -highlightthickness=>10,
> )->pack;

$mw->update;

Quote:
> $text->flash();
> MainLoop;

> This creates the button that I want, but it doesn't flash. This is using the
> Activestate Windows flavor of Perl. Am I  using flash() correctly or am I
> misinterpreting the documentation about the use and function of flash()??

The flash is getting lost amidst the initial display of the MainWindow.
Putting an update before the flash will cause the MainWindow and Button
to be displayed.  Then the flash will be visible for a second.  Try
additional consecutive flashes if you want more.

--
Marc Dashevsky  (remove "_" from address to reply by e-mail)



Tue, 24 Jun 2003 09:24:11 GMT  
 How do I use flash()
Well that works great! Now my problem is that what I had imagined that
flash() would output isn't exactly the same as what it does :-O   I can make
it do what I want now that I know what it does & doesnt do.

Thanks
Phil Sheridan


Quote:

says...
> > Hi all, newbie question here, I have a listener that monitors tcp and
spawns
> > off a button to notify person at the console of an new incoming message.
I
> > would like the button to flash on and off continuously when it pops up.
I am
> > using the following code:

> > use strict;
> > use Tk;
> > my $messagetime=localtime();
> > my $mw=MainWindow->new(-title=>'NEW MESSAGE',-bg=>'blue');

> > my $text=$mw->Button(
> > -bd=>10,
> > -relief=>'ridge',
> > -state=>'active',
> > -fg=>'green',
> > -bg=>'blue',
> > -activebackground=>'red',
> > -activeforeground=>'white',
> > -text=>$messagetime,
> > command=>sub{exit},
> > -highlightthickness=>10,
> > )->pack;

> $mw->update;

> > $text->flash();
> > MainLoop;

> > This creates the button that I want, but it doesn't flash. This is using
the
> > Activestate Windows flavor of Perl. Am I  using flash() correctly or am
I
> > misinterpreting the documentation about the use and function of
flash()??

> The flash is getting lost amidst the initial display of the MainWindow.
> Putting an update before the flash will cause the MainWindow and Button
> to be displayed.  Then the flash will be visible for a second.  Try
> additional consecutive flashes if you want more.

> --
> Marc Dashevsky  (remove "_" from address to reply by e-mail)



Tue, 24 Jun 2003 10:03:09 GMT  
 How do I use flash()


Quote:
> Well that works great! Now my problem is that what I had imagined that
> flash() would output isn't exactly the same as what it does :-O   I
can make
> it do what I want now that I know what it does & doesnt do.

I 'imagined' the exact same thing 5 years ago. AFAIK flash 'should' mean
flash it intermittently and  consistently. However, in the Tk context it
is more like a camera flashbulb rather than a neon sign over a bar on
Bourbon St:-)

This is easily done by configuring colors or fonts intermittently. Using
your example:

#######################################
use strict;
use Tk;
my $messagetime=localtime();
my $mw=MainWindow->new(-title=>'NEW MESSAGE',-bg=>'blue');
my $text=$mw->Button(
 -bd=>10,
 -relief=>'ridge',
 -state=>'active',
 -fg=>'green',
 -bg=>'blue',
 -activebackground=>'red',
 -activeforeground=>'white',
 -text=>$messagetime,
 -command=>sub{exit},
 -highlightthickness=>10,
 )->pack;

 $mw->repeat(500,\&alternate_colors);

 MainLoop;

sub alternate_colors
{
        my $fg=$text->cget(-foreground);
        my $bg=$text->cget(-background);
        my $activefg=$text->cget(-activeforeground);
        my $activebg=$text->cget(-activebackground);
        $text->configure(
                -fg=>$bg,
                -bg=>$fg,
                -activeforeground=>$activebg,
                -activebackground=>$activefg);

Quote:
}

###############################################

Sent via Deja.com
http://www.deja.com/



Tue, 24 Jun 2003 12:13:39 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Flash and Forms in Flash and forms

2. PERLFUNC: endservent - be done using services file

3. PERLFUNC: endpwent - be done using passwd file

4. PERLFUNC: endprotoent - be done using protocols file

5. PERLFUNC: endnetent - be done using networks file

6. PERLFUNC: endhostent - be done using hosts file

7. PERLFUNC: endgrent - be done using group file

8. PERLFUNC: endservent - be done using services file

9. PERLFUNC: endpwent - be done using passwd file

10. PERLFUNC: endprotoent - be done using protocols file

11. PERLFUNC: endnetent - be done using networks file

12. PERLFUNC: endhostent - be done using hosts file

 

 
Powered by phpBB® Forum Software