Python Forum
[WxPython] StaticBitmap: unexpected behaviour
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[WxPython] StaticBitmap: unexpected behaviour
#1
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.text.SetBackgroundColour((255,255,255))
self.imageCtrl = wx.StaticBitmap(self.panel, wx.ID_ANY, wx.BitmapFromImage("myImg.png"))
self.box_output.Add(self.text,1,wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL,5)
self.box_output.Add(self.imageCtrl,2,wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL,1)

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")
     self.imageCtrl.SetBitmap(bmp)
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?

Thanks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Generate ctrl-A behaviour edgarfinchley 3 2,697 Aug-24-2018, 01:13 PM
Last Post: Larz60+
  [WxPython] wx.StaticBitmap change image royer14 4 8,387 Jul-02-2018, 02:35 PM
Last Post: royer14

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020