def OnLoad(self, evt=None): try: result = load_csv(self) if result is None: return has_header, values, _ = result if has_header: port_values = values[1:] else: port_values = values if len(port_values) != len(self.vsrc.ports): raise ValueError('Invalid number of ports.') for i, port_value in enumerate(port_values): if len(port_value) != 2: raise ValueError('Invalid number of settings for port {0}.'.format(i)) try: float(port_value[0]) float(port_value[1]) except TypeError: raise ValueError('Not a number for port {0}.'.format(i)) except (IOError, ValueError) as e: MessageDialog(self, str(e), 'Load error').Show() return for port, values in zip(self.vsrc.ports, port_values): port.gain = float(values[0]) port.offset = float(values[1])
def OnLoad(self, evt=None): try: result = load_csv(self) if result is None: return has_header, values, _ = result if has_header: port_values = values[1:] else: port_values = values if len(port_values) != len(self.vsrc.ports): raise ValueError('Invalid number of ports.') for i, port_value in enumerate(port_values): if len(port_value) != 2: raise ValueError( 'Invalid number of settings for port {0}.'.format(i)) try: float(port_value[0]) float(port_value[1]) except TypeError: raise ValueError('Not a number for port {0}.'.format(i)) except (IOError, ValueError) as e: MessageDialog(self, str(e), 'Load error').Show() return for port, values in zip(self.vsrc.ports, port_values): port.gain = float(values[0]) port.offset = float(values[1])
def OnMenuFileOpen(self, evt=None): try: result = load_csv(self.csv_frame) except IOError as e: MessageDialog(self.csv_frame, str(e), 'Could not load data').Show() return if result is None: return else: self.OnMenuFileClose() has_header, values, filename = result self.csv_frame.display_panel.from_csv_data(has_header, values) self.csv_frame.Title = '{0} - {1}'.format(filename, self.default_title) self.update_plot_menus(len(self.csv_frame.display_panel) > 0) self.filter_menu_item.Enable(True)