darkwing 0 Newbie Poster

Hi all,

I'm trying to write a video player with wxpython and pygst. The main Frame has one panel and one notebook. On one page of the notebook, I need to play multiple videos at the same time. On this page, I declare two CameraPanel instances (code below) and put them in a horizontal sizer.

class CameraPanel (wx.Panel):
    def __init__(self, parent, stream):
        wx.Panel.__init__(self, parent)
        self.SetMinSize((320,240))
        self.player = gst.parse_launch(stream)
        bus = self.player.get_bus()
        bus.add_signal_watch()
        bus.enable_sync_message_emission()
        bus.connect('message', self.on_message)
        bus.connect('sync-message::element', self.on_sync_message)
    
    def on_message(self, bus, message):
        t = message.type
        if t == gst.MESSAGE_EOS:
            self.player.set_state(gst.STATE_NULL)
            #self.button.SetLabel("Start")
        elif t == gst.MESSAGE_ERROR:
            self.player.set_state(gst.STATE_NULL)
            #self.button.SetLabel("Start")
  
    def on_sync_message(self, bus, message):
        if message.structure is None:
            return
        message_name = message.structure.get_name()
        if message_name == 'prepare-xwindow-id':
            imagesink = message.src
            imagesink.set_property('force-aspect-ratio', True)
            imagesink.set_xwindow_id(self.GetHandle())

I usually get the BadWindow error when trying to run and the program crashes. When it doesn't crash and actually plays the video, it output them in two separate X windows and not on the notebook page. If I just try to play one video, it works all the time. The problem comes in when I try to play the second video. Can somebody point me in the right direction? I can provide more code if necessary. The declaration of the notebook and its tab is below.

window = wx.Frame(None)
        self.camera_tab = wx.Notebook(window)
        self.page1 = wx.Panel(self.camera_tab)
        self.page2 = CameraPanel(self.page1, stream)
        self.page3 = CameraPanel1(self.page1, stream)

Thanks,