Hi,
I would like to change the text written on a ToolBar button after the
ToolBar has been created and Realized. SetLabel works in the sense
that a subsequent call to GetLabel returns the new text, however, the
ToolBar does not actually get updated.
Below is a simple example demonstrating this. The screen output
suggests the label has been changed, but the text on the button
remains the same.
Is there a way of relabeling the tool without destroying and
recreating the toolbar?
Thanks!
Bruce
#!/usr/bin/perl
package MyApp;
use base 'Wx::App';
use strict;
use warnings;
use Wx qw(:everything);
use Wx::ArtProvider qw/:artid :clientid/;
sub OnInit {
my $frame = Wx::Frame -> new(undef, -1, 'toolbar demo',
[-1, -1], [250, 150], );
my $tb = Wx::ToolBar -> new($frame, -1,
wxDefaultPosition, wxDefaultSize,
wxTB_HORIZONTAL|wxTB_3DBUTTONS|wxTB_TEXT);
my $first = $tb -> AddTool(-1, "One thing",
Wx::Bitmap->new( 10, 10, -1 ),
wxNullBitmap, wxITEM_NORMAL, q{}, q{} );
my $second = $tb -> AddTool(-1, "Another",
Wx::Bitmap->new( 10, 10, -1 ),
wxNullBitmap, wxITEM_NORMAL, q{}, q{} );
$tb -> Realize;
$frame -> Show(1);
print $second->GetLabel, $/;
$second -> SetLabel("fresh and new");
$tb -> Realize;
#$tb -> Update; ## what goes here???
print $second->GetLabel, $/;
};
package main;
use Wx qw(:everything);
Wx::InitAllImageHandlers();
my $app = MyApp->new;
$app->MainLoop;
--
Bruce Ravel ------------------------------------ [email protected]
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/