def importScript(self, scriptfile = ''): if not self.isVisible(): self.show() if scriptfile == '': scriptfile= file_manager.getOpenFileName(parent=self, caption='Load script', filter=('Python files (*.py);;Text files (*.txt);;All files (*.*)')) if scriptfile == None or not os.path.exists(scriptfile): return editor = Editor(scriptfile) self.addEditor(editor)
def __init__(self): super().__init__() uic.loadUi('speechrecognition.ui', self) self.r = sr.Recognizer() self.m = sr.Microphone() self.recording = False self.actionRecord_Background.triggered.connect(self.record_background) self.actionClear_Background.triggered.connect(self.clear_background) self.startButton.pressed.connect(self.toggle_recording) self.actionOpen_File.triggered.connect(lambda : self.read_file(fm.getOpenFileName(filter='*.wav')))
def teach_gui(self): if not hasattr(self, 'ui'): self.ui = uic.loadUi('LetterClassifier.ui') self.ui.consoleWidget.localNamespace.update({'classifier': self, 'plot': self.ui.plotWidget, 'player': self.player, 'ui': self.ui, "recorderWidget": self.ui.recorderWidget}) self.ui.actionOpen.triggered.connect(lambda : self.plotWavFile(file_manager.getOpenFileName())) self.ui.actionSave_Memory.triggered.connect(lambda : self.save(file_manager.getSaveFileName())) self.ui.menuRecent_Files.aboutToShow.connect(self.build_recent_actions) self.ui.browseButton.pressed.connect(lambda : self.plotWavFile(file_manager.getOpenFileName())) self.ui.learnButton.pressed.connect(self.ui_learn_pressed) self.ui.unlearnButton.pressed.connect(self.ui_unlearn_pressed) self.ui.loadButton.pressed.connect(lambda : self.load_mem(file_manager.getOpenFileName())) self.ui.clearMemButton.pressed.connect(lambda : self.clear_memory(erase=False)) self.ui.predictButton.pressed.connect(self.ui_predict_pressed) self.ui.outputTree.itemClicked.connect(self.ui_tree_clicked) self.ui.setAcceptDrops(True) self.ui.playButton.pressed.connect(self.play_selection) self.ui.eventFilter = self.eventFilter self.ui.installEventFilter(self.ui) self.build_recent_actions() self.ui.closeEvent = lambda ev: self.save() self.ui.show() self.updateTreeView()
def addChannel(self, name=None, data=[], color=[]): if name == None: name = fm.getOpenFileName(filter='Text Files (*.txt)') if name == '': return if len(data) == 0: self.fileWidget = FileViewWidget(name) self.fileWidget.accepted.connect(lambda d : self.addChannel(name, d, color=self.fileWidget.color)) self.fileWidget.show() return if len(color) != 4: color = (np.random.randint(255), np.random.randint(255), np.random.randint(255), 255) name = os.path.basename(name) if name in np.unique(self.data['File']): name += '_copy' data.insert(0, 'File', name) self.update(data=pd.concat([self.data, data]), colors={'File': {os.path.basename(name): color}})
def importROIs(self): fname = fm.getOpenFileName(filter='Text Files (*.txt)') if fname == '': return ROIVisual.importROIs(fname, self)
def open_file_gui(func, filetypes, prompt='Open File', args=[]): filename= file_manager.getOpenFileName(caption=prompt, filter=filetypes) if filename != '': func(filename, *args)