Dynamic Resizing and Centering Image.

mkey wrote:

Hello, all

Thank you for your help on this matter.

Based on Mike's advice, I added EVT_SIZE event handler to Chris's sample code.
Now, this sample can resize and centering dynamically.

By handling the EVT_SIZE yourself you prevent the sizer from doing its job, so you may as well not be using it. On the other hand the sizer is perfectly capable of doing the centering for you, you just need to tell it to do so when the size of the widgets you are managing changes. Try it out by removing the EVT_SIZE binding and then add a call to self.Layout() at the end of DisplayNext.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Based on Mike's advice, I added EVT_SIZE event handler to Chris's sample code.

By handling the EVT_SIZE yourself you prevent the sizer from doing its job, so you may as well not be using it.

You've also changed the functionality -- your EVT_SIZE handler is re-scaling the image, changing it's aspect ratio -- that may be what you want, but it's not how the code I sent you is supposed to work. That code explicitly maintained the aspect ratio.

I've enclosed a slightly edited version -- I added a self.refresh() at the end of DisplayNext(). I didn't need that on OS-X, but apparently it's required on Windows.

> add a call to self.Layout() at the end of DisplayNext.

That doesn't seem to be required now that I've got the Refresh() call there.

-Chris

StaticBitmap.py (2.67 KB)

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov