Why does wxStaticBitmap display multiple ima ges instead of one [Newbie alert]

Amen!

···

----------
Vernon

-----Original Message-----
From: Steve Cronje [mailto:scronje@sasktel.net]
Sent: Thursday, January 01, 2004 9:22 AM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] Why does wxStaticBitmap display multiple
ima ges instead of one [Newbie alert]

On Wed, 2003-12-31 at 13:58, Chris Barker wrote:

I don't know what you're doing, but it's pretty simple. I've enclosed a
sample app that displays a set of jpgs in an "Image directory".

There have been enough questions about this, I just may put this in the
Wiki.

Thanks Chris

That was very helpful. I agree that it may be helpful in the Wiki.

Steve

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Vernon Cole wrote:

That was very helpful. I agree that it may be helpful in the Wiki.

OK, there's a new page in the Wiki:

http://wiki.wxpython.org/index.cgi/wxStaticBitmap

--Enjoy, Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (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

Hi all,

I just put a new page on the Wiki demostating changing the bitmap on a wxBitmap. I set it up with a wx.Sizer, so that the fraem woudl re-size itself to fit the StaticBitmap. However, I found I had to do:

         self.Image.SetSize( self.Image.GetBestSize() )

to reset the size before calling:

         self.Layout() self.Image.SetBitmap(wx.BitmapFromImage(Img))

to make the frame re-do the layout.

shouldn't the sizer use the BestSize anyway? is it a bug that I had to re-set it's size by hand?

The full demo app is at:

http://wiki.wxpython.org/index.cgi/wxStaticBitmap

Here is how the wx.StaticBitmap is put in the sizer:

         box = wx.BoxSizer(wx.VERTICAL)
         box.Add(b, 0, wx.CENTER | wx.ALL,10)
         box.Add(self.Image, 0, wx.CENTER | wx.ALL, 10)

( b is a wx.Button )

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (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

Chris Barker wrote:

Hi all,

I just put a new page on the Wiki demostating changing the bitmap on a wxBitmap. I set it up with a wx.Sizer, so that the fraem woudl re-size itself to fit the StaticBitmap. However, I found I had to do:

        self.Image.SetSize( self.Image.GetBestSize() )

to reset the size before calling:

        self.Layout() self.Image.SetBitmap(wx.BitmapFromImage(Img))

to make the frame re-do the layout.

shouldn't the sizer use the BestSize anyway? is it a bug that I had to re-set it's size by hand?

There is a flag for it. Use wx.ADJUST_MINSIZE when adding it to the sizer and then all you'll need to do is call Layout.

···

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

thanks, Robin. I've updated the wiwi page with this change. We may as well have code in the Wiki be a clean as possible.

-Chris

Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (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

···

On Friday, January 2, 2004, at 01:06 PM, Robin Dunn wrote:

shouldn't the sizer use the BestSize anyway? is it a bug that I had to re-set it's size by hand?

There is a flag for it. Use wx.ADJUST_MINSIZE when adding it to the sizer and then all you'll need to do is call Layout.