PDA

View Full Version : [SOLVED] [wxPython] Can't change the size of a wx.Bitmap or wx.StaticBitmap



dodle
June 15th, 2009, 07:01 PM
No matter what I try, the bitmap is displayed in its original dimensions.


image = wx.Bitmap("im.png")
mypic = wx.StaticBitmap(self, -1, image, wx.DefaultPosition, (50,50), wx.BITMAP_TYPE_PNG)

image = wx.Bitmap("im.png")
mypic = wx.StaticBitmap(self, -1, image, wx.DefaultPosition, style=wx.BITMAP_TYPE_PNG)
mypic.SetSize((50,50))

image = wx.Bitmap("im.png")
image.SetSize((50,50))
mypic = wx.StaticBitmap(self, -1, image, wx.DefaultPosition, style=wx.BITMAP_TYPE_PNG)

How can I change the dimensions of a displayed bitmap?

dodle
June 15th, 2009, 07:22 PM
I learned that I first needed to load the image as a wx.Image instead of wx.Bitmap. Then use the Rescale() module to size and convert it to a wx.Bitmap with BitmapFromImage().



start_image = wx.Image("im.png")
start_image.Rescale(50, 50)
image = wx.BitmapFromImage(start_image)
mypic = wx.StaticBitmap(self, -1, image, wx.DefaultPosition, style=wx.BITMAP_TYPE_PNG)