I have some images I want to display but I need to scale them to fit the frame (well the area in a nested sizer). I also want the images to auto-scale (keeping aspect ratio) to the available space provided by the sizer (as the window size is changed).
I’m using opencv and sci-kit/numpy to do scaling and setting a bitmap with
wx.Bitmap.FromBuffer() and then setting the static bitmap (native or generic) with
frame = cv.resize( frame, None, fx=0.5, fy=0.5 ) height, width = frame.shape[ : 2 ] bmp = wx.Bitmap.FromBuffer( width, height, frame ) self.raw_genericstaticbitmap.SetBitmap( bmp )
I’m not sure if there are any issues with the above and whether I’d be better off using
wx.Image to do the scaling.
Either way, I need to find someway to get the dimensions of the sizer slots to figure out the scaling values.
How do I do this?
I’ve tried looking at Size, MinSize, ClientSize, VirtualSize, EffectiveMinSize of the static bitmap widget, and even the containing sizer items, but none of the those values seem to change when I resize the frame.
Note the sizer may have multiple children (static bitmaps) to display multiple images, and the proportion is set to 1 so they get equal weighting during resize.
Maybe there is a simpler way altogether ?