$button->modify_bg() delay?



Hi, I'm writing a program in Gtk2-perl where I'd like to change the
background color of a button several times if a user hits the wrong
button. It seems that ->modify_bg() doesn't take effect until the
called subroutine finishes though. Is there a way around this?  Below
is a test program where the button is changed to green, then red. I
only ever see the red.

Also, how can I get the default colors for the three different states,
so they can be reset back to normal?

Any help would be much appreciated, thanks.


#!/usr/bin/perl

use strict;
use Gtk2 -init;

my $window = Gtk2::Window->new( 'toplevel' );
my $button = Gtk2::Button->new( 'Push me' );

$button->signal_connect( 'clicked', \&clicked );
$window->add( $button );
$window->show_all();

Gtk2->main;

sub clicked {
    my $green = Gtk2::Gdk::Color->parse( 'green' );
    my $red = Gtk2::Gdk::Color->parse( 'red' );

    $button->modify_bg( 'normal', $green );
    $button->modify_bg( 'active', $green );
    $button->modify_bg( 'prelight', $green );
    sleep 5;
    $button->modify_bg( 'normal', $red );
    $button->modify_bg( 'active', $red );
    $button->modify_bg( 'prelight', $red );
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]