views:

39

answers:

1

My Python code:

    self.images = wx.StaticBitmap(self, id=-1, pos=wx.DefaultPosition,
                            size=(200,150),
                            style= wx.SUNKEN_BORDER)
    self.hbox = wx.BoxSizer(wx.HORIZONTAL)
    self.sizer.Add(self.hbox) # my main sizer

    #in function dinamically captured images
    bmp = wx.BitmapFromImage(image)
    self.images.SetBitmap(bmp)
    self.hbox.Add(self.images, 1, wx.EXPAND | wx.ALL, 3)

...and after I want to add next image (another - I don't want to replace older) I have information "Adding a window to the same sizer twice?" How can I resolve this problem?

+1  A: 

In your function for dynamically captured images, you need to create a new staticBitmap rather than setting self.images which overwrites and therefore replaces...

So instead of

self.images.SetBitmap(bmp)

you need to do

newImage = wx.StaticBitmap(self, id=-1
                           size=(200,150),
                           style= wx.SUNKEN_BORDER
                           bitmap = bmp)


self.hbox.Add(newImage, 1, wx.EXPAND | wx.ALL, 3)
self.SetSizerAndFit(self.sizer)
self.Refresh()
self.Layout()
volting
Yeah, I think that works properly but it doesn't display images in self.hbox. I see only one image in the left-top corner of my main wx.Dialog... I am noob with python gui, I know ;)
Carolus89
See my updated answer I forgot the last line, self.SetSizerAndFit(), try that it should work.
volting
I supposed that didn't help ;/
Carolus89
I just noticed that you mentioned in your comment that your using a wx.Dialog, which makes a difference, so I added some more code at the end... Let me know if this works for you.
volting
No.. mayby problem is with hbox... When I add self.hbox without elemenets inside to self.sizer (self is wx.Dialog) - self.hbox is added to the left - top cornder - exacly where now images are dislaying...
Carolus89
Whoops, sorry I totally missed self.sizer... Sleep deprivation must be getting to me! Ill update my answer now!
volting
It works!! Thank you! ;) If you only tell my, how can I add scroll to my self.hbox ... ;)
Carolus89
Take a look at the `scrolledPanel` http://www.wxpython.org/docs/api/wx.lib.scrolledpanel.ScrolledPanel-class.html
volting