def __init__(self, parent, filename): super(LoadDialog, self).__init__(parent) self.setupUi(self) # init datatype combobox self.DataTypeComboBox.addItems(DTYPES_LABELS) self.DataTypeComboBox.setCurrentIndex(DTYPES.index(rawfile.datatype_float64)) self.filename = filename self.FileFormatComboBox.currentIndexChanged.connect(self.on_format_change) self.FileFormatComboBox.currentIndexChanged.connect(self.load_preview) self.DataTypeComboBox.currentIndexChanged.connect(self.load_preview) self.ByteOrderComboBox.currentIndexChanged.connect(self.load_preview) # Detect settings if futils.istextfile(self.filename): self.FileFormatComboBox.setCurrentIndex(1) # Detect sample rate fs = futils.get_sample_rate(filename) if fs: self.SampleFrequencySpinBox.setValue(fs) else: self.FileFormatComboBox.setCurrentIndex(0) if futils.is_little_endian(): self.ByteOrderComboBox.setCurrentIndex(0) else: self.ByteOrderComboBox.setCurrentIndex(1) self.load_preview()
def __init__(self, parent, fmt='binary', dtype='float64', byteorder='native'): super(SaveDialog, self).__init__(parent) self.setupUi(self) # init comboboxes self.FileFormatComboBox.addItems(FORMATS_LABELS) self.DataTypeComboBox.addItems(DTYPES_LABELS) self.ByteOrderComboBox.addItems(BYTEORDERS_LABELS) self.FileFormatComboBox.currentIndexChanged.connect( self.on_format_change) # Set defaults self.FileFormatComboBox.setCurrentIndex(FORMATS.index(fmt)) self.DataTypeComboBox.setCurrentIndex(DTYPES.index(dtype)) # Detect endianness if 'native' byteorder is selected if byteorder == rawfile.byteorder_native: if futils.is_little_endian(): self.ByteOrderComboBox.setCurrentIndex( BYTEORDERS.index(rawfile.byteorder_little_endian)) else: self.ByteOrderComboBox.setCurrentIndex( BYTEORDERS.index(rawfile.byteorder_big_endian)) else: self.ByteOrderComboBox.setCurrentIndex(BYTEORDERS.index(byteorder))
def __init__(self, parent, fmt=None, dtype='float64', byteorder='native'): fmt = fmt.title() if fmt is not None else DEFAULT_FORMAT super(SaveDialog, self).__init__(parent) self.setupUi(self) self.FileFormatComboBox.currentIndexChanged.connect(self.on_format_change) # init comboboxes self.FileFormatComboBox.addItems(FORMATS_LABELS) self.DataTypeComboBox.addItems(DTYPES_LABELS) self.ByteOrderComboBox.addItems(BYTEORDERS_LABELS) # Set defaults self.FileFormatComboBox.setCurrentIndex(FORMATS_LABELS.index(fmt)) self.DataTypeComboBox.setCurrentIndex(DTYPES.index(dtype)) # Detect endianness if 'native' byteorder is selected if byteorder == rawfile.byteorder_native: if futils.is_little_endian(): self.ByteOrderComboBox.setCurrentIndex(BYTEORDERS.index(rawfile.byteorder_little_endian)) else: self.ByteOrderComboBox.setCurrentIndex(BYTEORDERS.index(rawfile.byteorder_big_endian)) else: self.ByteOrderComboBox.setCurrentIndex(BYTEORDERS.index(byteorder))