class MainFrame(wx.Frame): def __init__(self, com_port): wx.Frame.__init__(self, None, title="openDAQ") self.Bind(wx.EVT_CLOSE, self.on_close) self.daq = DAQ(com_port) self.daq.enable_crc(1) self.hw_ver = self.daq.hw_ver() self.adc_gains = [] self.adc_offset = [] self.adc_gains, self.adc_offset = self.daq.get_cal() self.dac_gain = self.dac_offset = 0 self.dac_gain, self.dac_offset = self.daq.get_dac_cal() # Here we create a panel and a notebook on the panel self.p = wx.Panel(self) self.nb = wx.Notebook(self.p) # create the page windows as children of the notebook self.page1 = AdcPage(self.nb, self.adc_gains, self.adc_offset, self) self.page1.SetBackgroundColour('#ece9d8') self.page2 = DacPage(self.nb, self.dac_gain, self.dac_offset, self) self.page2.SetBackgroundColour('#ece9d8') # add the pages to the notebook with the label to show on the tab self.nb.AddPage(self.page1, "ADC") self.nb.AddPage(self.page2, "DAC") # finally, put the notebook in a sizer for the panel to manage # the layout sizer = wx.BoxSizer() sizer.Add(self.nb, 1, wx.EXPAND) self.p.SetSizer(sizer) sz = self.page1.GetSize() sz[1] += 80 sz[0] += 10 self.SetSize(sz) def on_close(self, event): dlg = wx.MessageDialog( self, "Do you really want to close this application?", "Confirm Exit", wx.OK | wx.CANCEL | wx.ICON_QUESTION) result = dlg.ShowModal() dlg.Destroy() if result == wx.ID_OK: self.Destroy() self.daq.close() def show_error_parameters(self): dlg = wx.MessageDialog( self, "Verify parameters", "Error!", wx.OK | wx.ICON_WARNING) dlg.ShowModal() dlg.Destroy()
class MainFrame(wx.Frame): def __init__(self, com_port): wx.Frame.__init__(self, None, title="openDAQ") self.Bind(wx.EVT_CLOSE, self.on_close) self.daq = DAQ(com_port) self.daq.enable_crc(1) self.hw_ver = self.daq.hw_ver self.adc_gains = [] self.adc_offset = [] self.adc_gains, self.adc_offset = self.daq.get_cal() self.dac_gain = self.dac_offset = 0 self.dac_gain, self.dac_offset = self.daq.get_dac_cal() # Here we create a panel and a notebook on the panel self.p = wx.Panel(self) self.nb = wx.Notebook(self.p) # create the page windows as children of the notebook self.page1 = AdcPage(self.nb, self.adc_gains, self.adc_offset, self) self.page1.SetBackgroundColour('#ece9d8') self.page2 = DacPage(self.nb, self.dac_gain, self.dac_offset, self) self.page2.SetBackgroundColour('#ece9d8') # add the pages to the notebook with the label to show on the tab self.nb.AddPage(self.page1, "ADC") self.nb.AddPage(self.page2, "DAC") # finally, put the notebook in a sizer for the panel to manage # the layout sizer = wx.BoxSizer() sizer.Add(self.nb, 1, wx.EXPAND) self.p.SetSizer(sizer) sz = self.page1.GetSize() sz[1] += 80 sz[0] += 10 self.SetSize(sz) def on_close(self, event): dlg = wx.MessageDialog( self, "Do you really want to close this application?", "Confirm Exit", wx.OK | wx.CANCEL | wx.ICON_QUESTION) result = dlg.ShowModal() dlg.Destroy() if result == wx.ID_OK: self.Destroy() self.daq.close() def show_error_parameters(self): dlg = wx.MessageDialog(self, "Verify parameters", "Error!", wx.OK | wx.ICON_WARNING) dlg.ShowModal() dlg.Destroy()