Python Forum

Full Version: StaticBitmap: unexpected behaviour
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everybody,

I am having a little issue with wx.StaticBitmap. I made a program using WxPython where i have several gadgets. At some point, i need to
have a wx.StaticBitmap next to a wx.StaticText, following the code

self.box_output = wx.BoxSizer(wx.HORIZONTAL)
self.text = wx.StaticText(self.panel, style=wx.TE_READONLY|wx.BORDER_SUNKEN | wx.TE_MULTILINE)
self.imageCtrl = wx.StaticBitmap(self.panel, wx.ID_ANY, wx.BitmapFromImage("myImg.png"))

Later in the code i add this sizer to another one and i set this last one as the main sizer.

So far so good, when i run the program it is all fine, all widgets are showed properly. I can see the image in the right position.
The problem shows up when i try to update the bitmpap with a new image. Following the code:

def readPattern(self, value):
     #i do other stuff here without touching the bitmap
     bmp = wx.BitmapFromImage("img.png")
The previous method is called from another method. When the method is called, the bitmap updates with the correct image but the position is
wrong, i can actually see the same image twice and overlapping. By resizing the window manually, evertything goes as expected and the image is in the rigth position..

Any suggestions?