Although your hint with *Static*Bitmap could have been a bit more verbose, it actually pointed me into the right direction.
It was a shot in the dark. Without code to test, you're relying a wxWidgets expert, one who has seen it all (and has ESP), will stop by perlmonks. Those guys hang out
over here :)
Anyway, I can't make this flicker (needs somethumb.jpg, somethumb2.jpg in cwd).
#!/usr/bin/perl --
use warnings;
use strict;
use Wx 0.86 qw(:everything);
my $app = Wx::SimpleApp->new;
my $f = Wx::Frame->new( undef, -1, "Testing Popup", [ -1, -1 ], [ 555,
+ 555 ] );
Wx::InitAllImageHandlers();
my $p =
Wx::Panel->new( $f, -1, wxDefaultPosition, [ 320, 240 ], wxSUNKEN_BO
+RDER );
$p->{b} = my $b =
Wx::Button->new( $p, -1, "GO", wxDefaultPosition, [ 50, 20 ], 0 );
# identify somethumb.jpg
# somethumb.jpg JPEG 105x78 105x78+0+0 8-bit DirectClass 4.24kb 0.000u
+ 0:01
# identify somethumb2.jpg
# somethumb2.jpg JPEG 105x78 105x78+0+0 8-bit DirectClass 4.1kb
$p->{im1} = Wx::Image->new( 'somethumb.jpg', wxBITMAP_TYPE_ANY, -1 );
$p->{im2} = Wx::Image->new( 'somethumb2.jpg', wxBITMAP_TYPE_ANY, -1 );
$p->{imc} = 'im1';
$p->{sbmp} = my $sbmp =
Wx::StaticBitmap->new( $p, -1, Wx::Bitmap->new( $p->{im1} ) );
$p->{sbz} = my $sbz =
Wx::StaticBoxSizer->new( Wx::StaticBox->new( $p, -1, 'Wx::StaticBoxS
+izer' ),
wxVERTICAL );
$sbz->Add( $b, 0, wxALIGN_RIGHT | wxALL, 5 );
$sbz->Add( $sbmp, 0, wxALIGN_RIGHT | wxALL, 5 );
$p->SetAutoLayout(1);
$p->SetSizer($sbz);
$p->Layout();
$sbz->Fit($f);
$sbz->SetSizeHints($f);
$f->CenterOnScreen;
$f->Show(1);
use Wx::Event 'EVT_BUTTON';
EVT_BUTTON(
$p, -1,
sub {
my ( $p, $e ) = @_;
if ( $p->{imc} eq 'im1' ) {
$p->{imc} = 'im2';
}
else {
$p->{imc} = 'im1';
}
my $image = $p->{ $p->{imc} };
$image->Rescale( 320, 240 );
$image = Wx::Bitmap->new($image);
if ( $image->Ok() ) {
$p->{sbmp}->Destroy; ##
$p->{sbmp} = Wx::StaticBitmap->new( $p, -1, $image );
$p->{sbz}->Add( $p->{sbmp}, 0, wxALIGN_RIGHT | wxALL, 0 );
$p->Layout();
$p->Refresh();
}
}
);
$app->SetTopWindow($f);
$app->MainLoop();
__END__