develooper Front page | perl.wxperl.users | Postings from April 2011

StatusBar

Thread Next
From:
Bruce Ravel
Date:
April 4, 2011 14:22
Subject:
StatusBar
Message ID:
201104041722.42238.bravel@bnl.gov

Hi,

I continue to be surprised by small differences in behavior on linux
and Windows.  

This time, the thing I'd like to do is to change the background color
of a StatusBar to indicate how urgently the status message should be
considered by the user.  In the following script, I try to change the
StatusBar background using a callback attached to a RadioBox.  This
works as I expect on Linux -- the StatusBar changes to ugly green and
red colors when those buttons are clicked.  On Windows, however,
nothing happens.  The callback is called, but the StatusBar background
color is unchanged.

Am I misunderstanding something about how the StatusBar is intended to
be used?  Or about how it is implemented on Windows?

Thanks again!
Bruce



#!/usr/bin/perl
package MyApp;
use base 'Wx::App';
use Wx qw(:everything);
use Wx::Event qw(EVT_RADIOBOX);

sub OnInit {
  my $frame  = Wx::Frame ->  new(undef, -1, 'demo', [-1,-1], [250,150]);
  my $sizer  = Wx::BoxSizer->new(wxVERTICAL);
  $frame->{statusbar} = $frame->CreateStatusBar;
  $frame->{radio} = Wx::RadioBox->new($frame, -1, "Colors", 
                                      wxDefaultPosition, wxDefaultSize,
                                      ['normal', 'green', 'red']);
  $sizer -> Add($frame->{radio}, 0, wxALL 5);
  $frame->{radio} -> SetSelection(0);
  EVT_RADIOBOX($frame, $frame->{radio}, \&change_color);

  $frame ->  SetSizer($sizer);
  $frame->{statusbar} -> PushStatusText("Started!");
  $frame ->  Show(1);
  1;
};

sub change_color {
  my ($frame, $event) = @_;
  my $choice = $frame->{radio}->GetSelection;
  my $color = ($choice == 1) ? Wx::Colour->new(0, 255, 0)
            : ($choice == 2) ? Wx::Colour->new(255, 0, 0)
            : wxNullColour;
  $frame->{statusbar} -> SetBackgroundColour($color);
};

package main;
use Wx qw(:everything);
my $app = MyApp->new->MainLoop;




-- 

 Bruce Ravel  ------------------------------------ bravel@bnl.gov

 National Institute of Standards and Technology
 Synchrotron Methods Group at NSLS --- Beamlines U7A, X24A, X23A2
 Building 535A
 Upton NY, 11973

 My homepage:    http://xafs.org/BruceRavel
 EXAFS software: http://cars9.uchicago.edu/~ravel/software/exafs/

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About