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 __init__(self, port): self.comunication_thread = None self.timer_thread = None wx.Frame.__init__( self, None, title="DAQControl", style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.RESIZE_BOX | wx.MAXIMIZE_BOX)) self.daq = DAQ(port) self.Bind(wx.EVT_CLOSE, self.on_close) if hasattr(sys, "frozen"): executable = sys.executable else: executable = __file__ icon_path = os.path.join(os.path.dirname(executable), 'resources', 'icon64.ico') icon = wx.Icon(icon_path, wx.BITMAP_TYPE_ICO) self.SetIcon(icon) self.status_bar = self.CreateStatusBar() self.status_bar.SetFieldsCount(2) info = self.daq.get_info() hw_ver = "[M]" if info[0] == 1 else "[S]" fw_ver = (str(info[1] / 100) + "." + str( (info[1] / 10) % 10) + "." + str(info[1] % 10)) self.status_bar.SetStatusText("H:%s V:%s" % (hw_ver, fw_ver), 0) # Here we create a panel and a notebook on the panel self.p = wx.Panel(self) self.note_book = wx.Notebook(self.p) # create the page windows as children of the notebook self.page_1 = PageOne(self.note_book, info[0], self) self.page_1.SetBackgroundColour('#ece9d8') self.page_3 = PageThree(self.note_book, self) self.page_3.SetBackgroundColour('#ece9d8') self.page_4 = PageFour(self.note_book, self) self.page_4.SetBackgroundColour('#ece9d8') # add the pages to the notebook with the label to show on the tab self.note_book.AddPage(self.page_1, "Analog I/O") self.note_book.AddPage(self.page_3, "Digital I/O") self.note_book.AddPage(self.page_4, "Timer-Counter") # finally, put the notebook in a sizer for the panel to manage # the layout sizer = wx.BoxSizer() sizer.Add(self.note_book, 1, wx.EXPAND) self.p.SetSizer(sizer) self.sizer = sizer sz = self.page_1.GetSize() sz[1] += 80 sz[0] += 10 self.SetSize(sz) self.daq.enable_crc(1) self.daq.set_analog(0) self.daq.set_port_dir(0)
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 __init__(self, port): self.comunication_thread = None self.timer_thread = None wx.Frame.__init__( self, None, title="DAQControl", style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.RESIZE_BOX | wx.MAXIMIZE_BOX)) self.daq = DAQ(port) self.Bind(wx.EVT_CLOSE, self.on_close) if hasattr(sys, "frozen"): executable = sys.executable else: executable = __file__ icon_path = os.path.join( os.path.dirname(executable), 'resources', 'icon64.ico') icon = wx.Icon(icon_path, wx.BITMAP_TYPE_ICO) self.SetIcon(icon) self.status_bar = self.CreateStatusBar() self.status_bar.SetFieldsCount(2) info = self.daq.get_info() hw_ver = "[M]" if info[0] == 1 else "[S]" fw_ver = ( str(info[1] / 100) + "." + str((info[1] / 10) % 10) + "." + str(info[1] % 10)) self.status_bar.SetStatusText("H:%s V:%s" % (hw_ver, fw_ver), 0) # Here we create a panel and a notebook on the panel self.p = wx.Panel(self) self.note_book = wx.Notebook(self.p) # create the page windows as children of the notebook self.page_1 = PageOne(self.note_book, info[0], self) self.page_1.SetBackgroundColour('#ece9d8') self.page_3 = PageThree(self.note_book, self) self.page_3.SetBackgroundColour('#ece9d8') self.page_4 = PageFour(self.note_book, self) self.page_4.SetBackgroundColour('#ece9d8') # add the pages to the notebook with the label to show on the tab self.note_book.AddPage(self.page_1, "Analog I/O") self.note_book.AddPage(self.page_3, "Digital I/O") self.note_book.AddPage(self.page_4, "Timer-Counter") # finally, put the notebook in a sizer for the panel to manage # the layout sizer = wx.BoxSizer() sizer.Add(self.note_book, 1, wx.EXPAND) self.p.SetSizer(sizer) self.sizer = sizer sz = self.page_1.GetSize() sz[1] += 80 sz[0] += 10 self.SetSize(sz) self.daq.enable_crc(1) self.daq.set_analog(0) self.daq.set_port_dir(0)
def ok_event(self, event): port_number = self.edit_hear.GetCurrentSelection() if port_number >= 0: self.button_ok.Show(False) self.edit_hear.Show(False) self.button_cancel.Show(False) self.gauge.Show() try: daq = DAQ(self.sample_list[port_number]) except: dlg = wx.MessageDialog( self, "Port in use. Select another port", "Error", wx.OK | wx.ICON_WARNING) dlg.ShowModal() dlg.Destroy() os.execl(sys.executable, sys.executable, * sys.argv) # Restart try: daq.get_info() dlg = wx.MessageDialog( self, "openDAQ calibration started", "Continue", wx.OK | wx.ICON_QUESTION) dlg.ShowModal() dlg.Destroy() self.port = self.sample_list[port_number] self.EndModal(1) except: dlg = wx.MessageDialog( self, "DAQControl not found", "Exit", wx.OK | wx.ICON_QUESTION) dlg.ShowModal() dlg.Destroy() self.port = 0 self.EndModal(0) else: dlg = wx.MessageDialog( self, "Not a valid port", "Retry", wx.OK | wx.ICON_QUESTION) dlg.ShowModal() dlg.Destroy()
def ok_event(self, event): port_number = self.edit_hear.GetCurrentSelection() if port_number >= 0: self.button_ok.Show(False) self.edit_hear.Show(False) self.button_cancel.Show(False) self.gauge.Show() try: daq = DAQ(self.sample_list[port_number]) except: dlg = wx.MessageDialog(self, "Port in use. Select another port", "Error", wx.OK | wx.ICON_WARNING) dlg.ShowModal() dlg.Destroy() os.execl(sys.executable, sys.executable, *sys.argv) # Restart try: daq.get_info() dlg = wx.MessageDialog(self, "openDAQ calibration started", "Continue", wx.OK | wx.ICON_QUESTION) dlg.ShowModal() dlg.Destroy() self.port = self.sample_list[port_number] self.EndModal(1) except: dlg = wx.MessageDialog(self, "DAQControl not found", "Exit", wx.OK | wx.ICON_QUESTION) dlg.ShowModal() dlg.Destroy() self.port = 0 self.EndModal(0) else: dlg = wx.MessageDialog(self, "Not a valid port", "Retry", wx.OK | wx.ICON_QUESTION) 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()
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()
"""Plotting a chart from a stream type experiment and use another experiment to generate the signal""" import os import time import matplotlib.pyplot as plt from opendaq import DAQ, ExpMode, Gains # Change here the serial port in which the openDAQ is connected port = '/dev/ttyUSB0' if os.name == 'posix' else 'COM3' # Connect to the device daq = DAQ(port) # Configure the first experiment, the one that will be plotted data_rate = 20 stream1 = daq.create_stream(ExpMode.ANALOG_IN, data_rate, continuous=True) stream1.analog_setup(pinput=8, gain=Gains.S.x1) # Configure the second experiment, a custom signal generated from a stream preload_buffer = [-2.5, -1, 0, 1, 2.5] stream2 = daq.create_stream(ExpMode.ANALOG_OUT, period=500, npoints=len(preload_buffer), continuous=True) stream2.load_signal(preload_buffer) # Initiate lists and variables t0 = 0.0 t = [] data = [] # Initiate the plot
"""Basic configuration for loading a signal, generate it through the analog output""" from __future__ import print_function import os import time from opendaq import DAQ, ExpMode, Gains # Change here the serial port in which the openDAQ is connected port = '/dev/ttyUSB0' if os.name == 'posix' else 'COM3' # Connect to the device daq = DAQ(port) # create a ramp signal with 4 samples signal = list(range(4)) stream1 = daq.create_stream(ExpMode.ANALOG_IN, 300, npoints=len(signal)) stream1.analog_setup(pinput=8, gain=Gains.S.x1) stream2 = daq.create_stream(ExpMode.ANALOG_OUT, 300, npoints=len(signal)) stream2.load_signal(signal) daq.start() while daq.is_measuring: time.sleep(1) print("data1", stream1.read()) daq.stop()
"""Create two streams, wait until they finish, and restart them again""" from __future__ import print_function import os import time from opendaq import DAQ, ExpMode, Gains # Change here the serial port in which the openDAQ is connected port = '/dev/ttyUSB0' if os.name == 'posix' else 'COM3' # Connect to the device daq = DAQ(port) # Set Analog voltage daq.set_analog(0.9) stream1 = daq.create_stream(ExpMode.ANALOG_IN, 200, npoints=20) stream1.analog_setup(pinput=8, gain=Gains.S.x1) stream2 = daq.create_stream(ExpMode.ANALOG_IN, 300, npoints=20) stream2.analog_setup(pinput=7, gain=Gains.S.x1) daq.start() while daq.is_measuring: time.sleep(1) print("data1: ", stream1.read()) print("data2: ", stream2.read()) print("start Again!")
"""Create two streams and stop them after a while""" from __future__ import print_function import os import time from opendaq import DAQ, ExpMode, Gains # Change here the serial port in which the openDAQ is connected port = '/dev/ttyUSB0' if os.name == 'posix' else 'COM3' # Connect to the device daq = DAQ(port) # Set Analog voltage daq.set_analog(0.9) stream1 = daq.create_stream(ExpMode.ANALOG_IN, 200, continuous=True) stream1.analog_setup(pinput=8, gain=Gains.S.x1) stream2 = daq.create_stream(ExpMode.ANALOG_IN, 300, continuous=True) stream2.analog_setup(pinput=7, gain=Gains.S.x1) daq.start() for i in range(4): time.sleep(1) print("data1: ", stream1.read()) print("data2: ", stream2.read()) daq.stop() daq.close()
class TestDAQ(unittest.TestCase): def setUp(self): self.daq = DAQ('sim') self.sim = self.daq.ser def tearDown(self): self.daq.close() def test_set_led(self): for color in LedColor: self.daq.set_led(color) assert self.sim.led_color == color def test_set_led_error(self): # invalid color self.assertRaises(ValueError, self.daq.set_led, 4) self.assertRaises(ValueError, self.daq.set_led, -1) def test_get_info(self): hw_ver, fw_ver, dev_id = self.daq.get_info() assert hw_ver == self.sim.hw_ver assert fw_ver == self.sim.fw_ver assert dev_id == self.sim.dev_id def test_pio(self): for pio in range(6): self.daq.set_pio(pio + 1, 1) assert self.sim.pios[pio] == 1 self.daq.set_pio(pio + 1, 0) assert self.sim.pios[pio] == 0 def test_pio_dir(self): for pio in range(6): self.daq.set_pio_dir(pio + 1, 1) assert self.sim.pios_dir[pio] == 1 self.daq.set_pio_dir(pio + 1, 0) assert self.sim.pios_dir[pio] == 0
def setUp(self): self.daq = DAQ('sim') self.sim = self.daq.ser
"""Drawing a simple chart in stream mode""" import os import time import matplotlib.pyplot as plt from opendaq import DAQ, ExpMode, Gains # Change here the serial port in which the openDAQ is connected port = '/dev/ttyUSB0' if os.name == 'posix' else 'COM3' # Connect to the device daq = DAQ(port) daq.set_analog(1) # set a fix voltage # Configure the experiment data_rate = 200 stream = daq.create_stream(ExpMode.ANALOG_IN, data_rate, continuous=True) stream.analog_setup(pinput=8, gain=Gains.S.x1) # Initiate lists and variables t0 = 0.0 t = [] data = [] # Initiate the plot fig = plt.figure() plt.ion() plt.show() # start the experiment
"""Drawing a real-time chart using command-response mode""" import os from time import sleep import matplotlib.pyplot as plt from opendaq import DAQ # Change here the serial port in which the openDAQ is connected port = '/dev/ttyUSB0' if os.name == 'posix' else 'COM3' # Connect to the device daq = DAQ(port) daq.conf_adc(8) # Reading in AN8 daq.read_adc() period = 0.05 # Initiate plot: fig = plt.figure() plt.ion() plt.show() # initiate lists t = [] data = [] for i in range(50): try: daq.set_analog(i / 50.0 + .5) # we will plot a ramp line
class MainFrame(wx.Frame): def __init__(self, port): self.comunication_thread = None self.timer_thread = None wx.Frame.__init__( self, None, title="DAQControl", style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.RESIZE_BOX | wx.MAXIMIZE_BOX)) self.daq = DAQ(port) self.Bind(wx.EVT_CLOSE, self.on_close) if hasattr(sys, "frozen"): executable = sys.executable else: executable = __file__ icon_path = os.path.join(os.path.dirname(executable), 'resources', 'icon64.ico') icon = wx.Icon(icon_path, wx.BITMAP_TYPE_ICO) self.SetIcon(icon) self.status_bar = self.CreateStatusBar() self.status_bar.SetFieldsCount(2) info = self.daq.get_info() hw_ver = "[M]" if info[0] == 1 else "[S]" fw_ver = (str(info[1] / 100) + "." + str( (info[1] / 10) % 10) + "." + str(info[1] % 10)) self.status_bar.SetStatusText("H:%s V:%s" % (hw_ver, fw_ver), 0) # Here we create a panel and a notebook on the panel self.p = wx.Panel(self) self.note_book = wx.Notebook(self.p) # create the page windows as children of the notebook self.page_1 = PageOne(self.note_book, info[0], self) self.page_1.SetBackgroundColour('#ece9d8') self.page_3 = PageThree(self.note_book, self) self.page_3.SetBackgroundColour('#ece9d8') self.page_4 = PageFour(self.note_book, self) self.page_4.SetBackgroundColour('#ece9d8') # add the pages to the notebook with the label to show on the tab self.note_book.AddPage(self.page_1, "Analog I/O") self.note_book.AddPage(self.page_3, "Digital I/O") self.note_book.AddPage(self.page_4, "Timer-Counter") # finally, put the notebook in a sizer for the panel to manage # the layout sizer = wx.BoxSizer() sizer.Add(self.note_book, 1, wx.EXPAND) self.p.SetSizer(sizer) self.sizer = sizer sz = self.page_1.GetSize() sz[1] += 80 sz[0] += 10 self.SetSize(sz) self.daq.enable_crc(1) self.daq.set_analog(0) self.daq.set_port_dir(0) 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.comunication_thread.stop_thread() self.timer_thread.stop_thread() 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() def daq_error(self, number=0, foo=0): error_str = ("DAQ invokes an error. Line number:" + str(number) + " in " + foo + " function.") dlg = wx.MessageDialog(self, error_str, "Error!", wx.OK | wx.ICON_WARNING) dlg.ShowModal() dlg.Destroy()
from opendaq import DAQ dq = DAQ("COM3") dq.set_analog(1) dq.device_info() print dq.read_all()
class TestDAQ(unittest.TestCase): def setUp(self): self.daq = DAQ('sim') self.sim = self.daq.ser def tearDown(self): self.daq.close() def test_set_led(self): for color in range(4): self.daq.set_led(color) assert self.sim.led_color == color def test_set_led_error(self): # invalid color self.assertRaises(ValueError, self.daq.set_led, 4) self.assertRaises(ValueError, self.daq.set_led, -1) def test_get_info(self): hw_ver, fw_ver, dev_id = self.daq.get_info() assert hw_ver == self.sim.hw_ver assert fw_ver == self.sim.fw_ver assert dev_id == self.sim.dev_id def test_pio(self): for pio in range(6): self.daq.set_pio(pio + 1, 1) assert self.sim.pios[pio] == 1 self.daq.set_pio(pio + 1, 0) assert self.sim.pios[pio] == 0 def test_pio_dir(self): for pio in range(6): self.daq.set_pio_dir(pio + 1, 1) assert self.sim.pios_dir[pio] == 1 self.daq.set_pio_dir(pio + 1, 0) assert self.sim.pios_dir[pio] == 0
"""Creating a stream, using digital trigger on D1 (falling edge) to start the experiment""" from __future__ import print_function import time import os from opendaq import DAQ, ExpMode, Gains, Trigger # Change here the serial port in which the openDAQ is connected port = '/dev/ttyUSB0' if os.name == 'posix' else 'COM3' # Connect to the device daq = DAQ(port) # Set Analog voltage daq.set_analog(0.9) stream1 = daq.create_stream(ExpMode.ANALOG_IN, 200, npoints=20, continuous=False) stream1.analog_setup(pinput=8, ninput=7, gain=Gains.S.x1) # Configure trigger (Digital input D1, value = 0 falling edge) stream1.trigger_setup(Trigger.DIN1, 0) daq.start() print("Waiting for trigger...") while daq.is_measuring: time.sleep(1)
class MainFrame(wx.Frame): def __init__(self, port): self.comunication_thread = None self.timer_thread = None wx.Frame.__init__( self, None, title="DAQControl", style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.RESIZE_BOX | wx.MAXIMIZE_BOX)) self.daq = DAQ(port) self.Bind(wx.EVT_CLOSE, self.on_close) if hasattr(sys, "frozen"): executable = sys.executable else: executable = __file__ icon_path = os.path.join( os.path.dirname(executable), 'resources', 'icon64.ico') icon = wx.Icon(icon_path, wx.BITMAP_TYPE_ICO) self.SetIcon(icon) self.status_bar = self.CreateStatusBar() self.status_bar.SetFieldsCount(2) info = self.daq.get_info() hw_ver = "[M]" if info[0] == 1 else "[S]" fw_ver = ( str(info[1] / 100) + "." + str((info[1] / 10) % 10) + "." + str(info[1] % 10)) self.status_bar.SetStatusText("H:%s V:%s" % (hw_ver, fw_ver), 0) # Here we create a panel and a notebook on the panel self.p = wx.Panel(self) self.note_book = wx.Notebook(self.p) # create the page windows as children of the notebook self.page_1 = PageOne(self.note_book, info[0], self) self.page_1.SetBackgroundColour('#ece9d8') self.page_3 = PageThree(self.note_book, self) self.page_3.SetBackgroundColour('#ece9d8') self.page_4 = PageFour(self.note_book, self) self.page_4.SetBackgroundColour('#ece9d8') # add the pages to the notebook with the label to show on the tab self.note_book.AddPage(self.page_1, "Analog I/O") self.note_book.AddPage(self.page_3, "Digital I/O") self.note_book.AddPage(self.page_4, "Timer-Counter") # finally, put the notebook in a sizer for the panel to manage # the layout sizer = wx.BoxSizer() sizer.Add(self.note_book, 1, wx.EXPAND) self.p.SetSizer(sizer) self.sizer = sizer sz = self.page_1.GetSize() sz[1] += 80 sz[0] += 10 self.SetSize(sz) self.daq.enable_crc(1) self.daq.set_analog(0) self.daq.set_port_dir(0) 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.comunication_thread.stop_thread() self.timer_thread.stop_thread() 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() def daq_error(self, number=0, foo=0): error_str = ( "DAQ invokes an error. Line number:" + str(number) + " in " + foo + " function.") dlg = wx.MessageDialog( self, error_str, "Error!", wx.OK | wx.ICON_WARNING) dlg.ShowModal() dlg.Destroy()