Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: Displaying changing images in Wx:: produces flicker

by Anonymous Monk
on Feb 28, 2009 at 08:04 UTC ( #747099=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Displaying changing images in Wx:: produces flicker
in thread Displaying changing images in Wx:: produces flicker

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__


Comment on Re^3: Displaying changing images in Wx:: produces flicker
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://747099]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (11)
As of 2015-07-06 09:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (70 votes), past polls