def __init__(self, parent): wx.Frame.__init__(self, parent, size=(640, 480)) self.camera = Camera(1) self.camera.set_resolution(960, 1280) self.video_view = VideoView(self, self.capture) self.video_view.start() box = wx.BoxSizer(wx.HORIZONTAL) box.Add(self.video_view, 1, wx.ALL | wx.EXPAND, 0) self.SetSizer(box) self.Centre() self.Bind(wx.EVT_CLOSE, self.on_close)
class Frame(wx.Frame): def __init__(self, parent): wx.Frame.__init__(self, parent, size=(640, 480)) self.camera = Camera(1) self.camera.set_resolution(960, 1280) self.video_view = VideoView(self, self.capture) self.video_view.start() box = wx.BoxSizer(wx.HORIZONTAL) box.Add(self.video_view, 1, wx.ALL | wx.EXPAND, 0) self.SetSizer(box) self.Centre() self.Bind(wx.EVT_CLOSE, self.on_close) def capture(self): return self.camera.capture_image(flush=0) def on_close(self, event): self.video_view.stop() event.Skip()