Hello Monks,
I've got a small problem related to WxPerl: I am constructing a GUI that displays an image in a corner, on top of a WxPanel. Based on actions somewhere else in the app, the app switches the displayed image. And as it seems over the great variety in approaches to display an image, I haven't got it quite right.
$this->{thumb_panel} = Wx::Panel->new($this->{parent}, -1, wxDefaultPo
+sition, [320, 240], wxSUNKEN_BORDER);
$this->{thumb_sb} = Wx::StaticBitmap->new($this->{thumb_panel}, -1, Wx
+::Bitmap->new("somethumb.jpg", wxBITMAP_TYPE_ANY));
Now, when I exchange the displayed image with
my $handler = Wx::JPEGHandler->new();
my $image = Wx::Image->new();
my $bmp;
$handler->LoadFile( $image, $file );
$image->Rescale(320,240);
$bmp = Wx::Bitmap->new($image);
if( $bmp->Ok() ) {
$this->{thumb_sb} = Wx::StaticBitmap->new($this->{thumb_panel}, -1
+, $bmp);
}
I experience flickering on the exchange. The image disappears for a second, or I can see "the switch taking place" or it starts out as a smaller square and zooms in on the 320x240 size (on windows) or (on Linux) first a formerly displayed image is shown, then replaced by the current one... something like that.
The parent window, a notebook, has wxCLIP_CHILDREN set - no effect. So would anyone please look at the above code and tell me if I am doing something completely wrong here. Or tell me that it is likely that the problem lies elsewhere in my code.
(and yes, I do need the resize on the exchange, as some displayed images might not be of 320x240 size, same with the check, as images might be damaged...)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.