I have an application which displays a jpg in a BoxSizer(wx.HORIZONTAL) in a panel, and while I can get the first one in where I want it I don’t grok how to replace it with a different one when the user changes the other data. The data is coming from a sqlite db, with one of the fields of the row being a path and file name of the next jpg.
Can anyone point me in the correct direction on this?
Thanks,
Mark
In my case recently, I found that the GenStaticBitmap doesn’t seem to erase itself when you call SetBitmap more than once, so I made a simple subclass to take care of this for me, here’s a mostly-complete example:
import wx.lib.statbmp
import wx.lib.scrolledpanel as scrolled
class updateableBitmap(wx.lib.statbmp.GenStaticBitmap):
def OnPaint(self, event):
wx.PaintDC(self).Clear()
super(updateableBitmap, self).OnPaint(event)
class updateableBitmapFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, "View updateableBitmap")
self.panel = scrolled.ScrolledPanel(self)
img = wx.EmptyImage(1000,1000)
self.imageCtrl = updateableBitmap(self.panel, wx.ID_ANY, wx.BitmapFromImage(img))
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.AddF(self.imageCtrl, wx.SizerFlags(0).Expand())
self.panel.SetSizer(self.sizer)
def updateBMP(self, bmp):
self.imageCtrl.SetBitmap(bmp)
self.panel.Layout()
self.sizer.Layout()
self.Refresh()
···
On Wednesday, October 29, 2014 5:51:41 PM UTC-7, Mark Halegua wrote:
I have an application which displays a jpg in a BoxSizer(wx.HORIZONTAL) in a panel, and while I can get the first one in where I want it I don’t grok how to replace it with a different one when the user changes the other data. The data is coming from a sqlite db, with one of the fields of the row being a path and file name of the next jpg.
Can anyone point me in the correct direction on this?
Thanks,
Mark
I think I solved this once by saving the sizer item that holds the
bitmap, calling the DestroyWindows method, creating thenew bitmap, and
attaching it to the sizer item.
There may be a cleaner way to do this.
···
On Thu, Oct 30, 2014 at 10:13 AM, Nathan McCorkle <nmz787@gmail.com> wrote:
In my case recently, I found that the GenStaticBitmap doesn't seem to erase
itself when you call SetBitmap more than once, so I made a simple subclass
to take care of this for me, here's a mostly-complete example:
import wx.lib.statbmp
import wx.lib.scrolledpanel as scrolled
class updateableBitmap(wx.lib.statbmp.GenStaticBitmap):
def OnPaint(self, event):
wx.PaintDC(self).Clear()
super(updateableBitmap, self).OnPaint(event)
class updateableBitmapFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, "View updateableBitmap")
self.panel = scrolled.ScrolledPanel(self)
img = wx.EmptyImage(1000,1000)
self.imageCtrl = updateableBitmap(self.panel, wx.ID_ANY,
wx.BitmapFromImage(img))
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.AddF(self.imageCtrl, wx.SizerFlags(0).Expand())
self.panel.SetSizer(self.sizer)
def updateBMP(self, bmp):
self.imageCtrl.SetBitmap(bmp)
self.panel.Layout()
self.sizer.Layout()
self.Refresh()
On Wednesday, October 29, 2014 5:51:41 PM UTC-7, Mark Halegua wrote:
I have an application which displays a jpg in a BoxSizer(wx.HORIZONTAL) in
a panel, and while I can get the first one in where I want it I don't grok
how to replace it with a different one when the user changes the other data.
The data is coming from a sqlite db, with one of the fields of the row being
a path and file name of the next jpg.
Can anyone point me in the correct direction on this?
Thanks,
Mark
--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Josh English
Joshua.R.English@gmail.com
http://www.joshuarenglish.com