def widget_select(self, item): if self.audiowidget is not None: self.audiowidget.close() self.audiowidget.deleteLater() self.type = item if item is 0: self.audiowidget = Levels_Widget(self, self.logger) elif item is 1: self.audiowidget = Scope_Widget(self, self.sharedGLWidget, self.logger) elif item is 2: self.audiowidget = Spectrum_Widget(self, self.sharedGLWidget, self.logger) elif item is 3: self.audiowidget = Spectrogram_Widget(self, self.parent().audiobackend, self.logger) elif item is 4: self.audiowidget = OctaveSpectrum_Widget(self, self.logger) elif item is 5: self.audiowidget = Generator_Widget(self, self.parent().audiobackend, self.logger) elif item is 6: self.audiowidget = Delay_Estimator_Widget(self, self.logger) self.audiowidget.set_buffer(self.parent().audiobuffer) self.layout.addWidget(self.audiowidget) self.controlBar.comboBox_select.setCurrentIndex(item)
def widget_select(self, item): if self.audiowidget is not None: self.audiowidget.close() self.type = item if item is 0: self.audiowidget = Levels_Widget(self, self.logger) elif item is 1: self.audiowidget = Scope_Widget(self, self.logger) elif item is 2: self.audiowidget = Spectrum_Widget(self, self.logger) elif item is 3: self.audiowidget = Spectrogram_Widget(self, self.logger) self.audiowidget.timer.start() elif item is 4: self.audiowidget = OctaveSpectrum_Widget(self, self.logger) elif item is 5: self.audiowidget = Generator_Widget( self, self.parent.parent().audiobackend, self.logger) self.audiowidget.set_buffer(self.parent.parent().audiobuffer) if self.audiowidget.update is not None: self.connect(self.parent.parent().display_timer, QtCore.SIGNAL('timeout()'), self.audiowidget.update) self.layout.addWidget(self.audiowidget) self.controlBar.comboBox_select.setCurrentIndex(item)
def widget_select(self, item): if self.audiowidget is not None: self.audiowidget.close() self.audiowidget.deleteLater() self.type = item if item is 0: self.audiowidget = Levels_Widget(self, self.logger) elif item is 1: self.audiowidget = Scope_Widget(self, self.logger) elif item is 2: self.audiowidget = Spectrum_Widget(self, self.logger) elif item is 3: self.audiowidget = Spectrogram_Widget(self, self.parent().audiobackend, self.logger) elif item is 4: self.audiowidget = OctaveSpectrum_Widget(self, self.logger) elif item is 5: self.audiowidget = Generator_Widget(self, self.parent().audiobackend, self.logger) elif item is 6: self.audiowidget = Delay_Estimator_Widget(self, self.logger) elif item is 7: self.audiowidget = LongLevelWidget(self, self.logger) else: self.audiowidget = Levels_Widget(self, self.logger) self.audiowidget.set_buffer(self.parent().audiobuffer) self.parent().audiobuffer.new_data_available.connect( self.audiowidget.handle_new_data) self.layout.addWidget(self.audiowidget) self.control_bar.combobox_select.setCurrentIndex(item)
def __init__(self): QMainWindow.__init__(self) self.logger = logging.getLogger(__name__) # exception hook that logs to console, file, and display a message box self.errorDialogOpened = False sys.excepthook = self.excepthook # Setup the user interface self.ui = Ui_MainWindow() self.ui.setupUi(self) # Initialize the audio data ring buffer self.audiobuffer = AudioBuffer() # Initialize the audio backend # signal containing new data from the audio callback thread, processed as numpy array AudioBackend().new_data_available.connect( self.audiobuffer.handle_new_data) # this timer is used to update widgets that just need to display as fast as they can self.display_timer = QtCore.QTimer() self.display_timer.setInterval( SMOOTH_DISPLAY_TIMER_PERIOD_MS) # constant timing # slow timer self.slow_timer = QtCore.QTimer() self.slow_timer.setInterval(SLOW_TIMER_PERIOD_MS) # constant timing self.about_dialog = About_Dialog(self, self.slow_timer) self.settings_dialog = Settings_Dialog(self) self.level_widget = Levels_Widget(self) self.level_widget.set_buffer(self.audiobuffer) self.audiobuffer.new_data_available.connect( self.level_widget.handle_new_data) self.hboxLayout = QHBoxLayout(self.ui.centralwidget) self.hboxLayout.setContentsMargins(0, 0, 0, 0) self.hboxLayout.addWidget(self.level_widget) self.centralLayout = TileLayout() self.centralLayout.setContentsMargins(0, 0, 0, 0) self.hboxLayout.addLayout(self.centralLayout) self.dockmanager = DockManager(self) # timer ticks self.display_timer.timeout.connect(self.dockmanager.canvasUpdate) self.display_timer.timeout.connect(self.level_widget.canvasUpdate) self.display_timer.timeout.connect(AudioBackend().fetchAudioData) # toolbar clicks self.ui.actionStart.triggered.connect(self.timer_toggle) self.ui.actionSettings.triggered.connect(self.settings_called) self.ui.actionAbout.triggered.connect(self.about_called) self.ui.actionNew_dock.triggered.connect(self.dockmanager.new_dock) # restore the settings and widgets geometries self.restoreAppState() # make sure the toolbar is shown # in case it was closed by mistake (before it was made impossible) self.ui.toolBar.setVisible(True) # prevent from hiding or moving the toolbar self.ui.toolBar.toggleViewAction().setVisible(True) self.ui.toolBar.setMovable(False) self.ui.toolBar.setFloatable(False) # start timers self.timer_toggle() self.slow_timer.start() self.logger.info("Init finished, entering the main loop")