def __onLoadMazeButtonPressed(self) -> None: fileDialog = QFileDialog(self, "Open a maze file…") filesFilter = "Maze files (*.maze, *.db)" fileDialog.setFileMode(QFileDialog.FileMode.ExistingFile) filePath: str = "" filePath = fileDialog.getOpenFileName(filter=filesFilter)[0] self.__onMazeFilePathChosen(filePath)
def open_project(self): ''' open a decomp project, initialize ui accordingly ''' dlg = QFileDialog() project_dir = dlg.getExistingDirectory() if project_dir: self.root = project_dir self.load_project() self.mainwindow.tabWidget.setEnabled(True) pass
def selectImageDataFile(self): file_path = os.path.join(self.experiment_file_directory, self.experiment_file_name + '.hdf5') image_file_path, _ = QFileDialog.getOpenFileName( self, "Select image file") print('User selected image file at {}'.format(image_file_path)) self.image_file_name = os.path.split(image_file_path)[-1] self.data_directory = os.path.split(image_file_path)[:-1][0] h5io.attachImageFileName(file_path, self.series_number, self.image_file_name) print('Attached image_file_name {} to series {}'.format( self.image_file_name, self.series_number)) print('Data directory is {}'.format(self.data_directory)) self.currentImageFileNameLabel.setText(self.image_file_name) # show roi image if self.series_number is not None: if self.data_directory is not None: # user has selected a raw data directory self.plugin.updateImageSeries( data_directory=self.data_directory, image_file_name=self.image_file_name, series_number=self.series_number, channel=self.current_channel) self.roi_image = self.plugin.mean_brain self.zSlider.setValue(0) self.zSlider.setMaximum(self.roi_image.shape[2] - 1) self.redrawRoiTraces() else: print('Select a data directory before drawing rois')
def setOutputPath(self): # update the output path path = str(QFileDialog.getExistingDirectory(self, "Select Output Directory")) if path: self.outputPath = path # update tooltip self.outputBtn.setToolTip(path)
def load_configuration_window(self) -> None: self.force_bypass_notification = True self.configuration_path_input.setText( QFileDialog.getOpenFileName( self, "Open Configuration File", str(pathlib.Path(__file__).parent.resolve()), "CDS Configuration (*.json);;All Files (*)")[0])
def __init__(self, **kwargs): super().__init__() self.setupUi(self) self.events = kwargs.get('events') # type: dict self.config = self.events['get_config']() # type:Config self.f_dialog = QFileDialog() self.t_sync = TSync() self._event_connect() self.load_language() self.init_languages_menu() self.load_data()
def inclusions_add(self): path = QFileDialog.getExistingDirectory() if path and not self.inclusions_list_widget.findItems( path, Qt.MatchFlag.MatchExactly ): self.inclusions_list_widget.addItem(path) self.logger.info("Inclusion added.")
def _edit_path_button_clicked(self): path = str( QFileDialog.getExistingDirectory( self, "Choose a directory of text files.")) if path != "": path = f"{path}/*.txt" self.path.setText(path)
def file_open(self): self.iw.scene.clear() self.image_name = QFileDialog.getOpenFileName(self, 'Open File') self.iw.pixmap = QtGui.QPixmap(self.image_name[0]) self.iw.pixmap_fit = self.iw.pixmap.scaled( self.iw.pixmap.width(), self.iw.pixmap.height(), QtCore.Qt.AspectRatioMode.KeepAspectRatio, transformMode=QtCore.Qt.TransformationMode.SmoothTransformation) self.iw.scene.addPixmap(self.iw.pixmap_fit) #add image self.iw.setScene(self.iw.scene) #Adjust window size automatically? self.iw.fitInView(self.iw.scene.sceneRect(), QtCore.Qt.AspectRatioMode.KeepAspectRatio) self.iw.scene.update() self.statusbar.showMessage('Select a measurement to make from the toolbar') self.lengthButton.setEnabled(True) self.areaButton.setEnabled(True) self.angleButton.setEnabled(True) self.exportButton.setEnabled(True) self.undoButton.setEnabled(True) self.bezier.setEnabled(True) self.bezier.setChecked(True) self.widthsButton.setEnabled(False) self.angleNames = [] self.areaNames = [] self.lengthNames = [] #self.iw.measurements = [[]] self.iw.widths = [] self.iw.lengths = [[]] self.iw.L = posData( np.empty(shape=(0, 0)), np.empty(shape=(0, 0))) #lengths self.iw.A = posData( np.empty(shape=(0, 0)), np.empty(shape=(0, 0))) #area self.iw.W = posData( np.empty(shape=(0, 0)), np.empty(shape=(0, 0))) #widths self.iw.T = angleData(np.empty(shape=(0, 0))) #angles self.iw.angleValues = np.empty((0,0)) self.iw.areaValues = np.empty((0,0)) self.iw._lastpos = None self.iw._thispos = None self.iw.measuring_length = False self.iw.measuring_area = False self.iw.measuring_widths = False self.iw.measuring_angle = False self.iw._zoom = 0 self.iw.factor = 1.0 self.iw.d = {} #dictionary for line items self.iw.k = 0 #initialize counter so lines turn yellow self.iw.m = None self.iw.scene.realline = None self.iw.scene.testline = None self.iw.scene.ellipseItem = None self.iw.scene.area_ellipseItem = None self.iw.scene.polyItem = None self.iw.image_name = None
def save_configuration(self, configuration: Union[Dict[str, Any], None]) -> None: self.save_to_file( configuration, QFileDialog.getSaveFileName( self, "Save Configuration", str(pathlib.Path(__file__).parent.resolve()), "CDS Configuration (*.json);;All Files (*)")[0])
def load_matching_phase_from_config_task(self): logger.info("Execute task 'load_matching_phase_from_config_task'.") path = str(QFileDialog.getOpenFileName(self, "Choose a configuration .json file!")[0]) if path != "": self.disable_global_input() # noinspection PyUnresolvedReferences self.load_matching_phase_from_config.emit(path)
def load_document_base_from_bson_task(self): logger.info("Execute task 'load_document_base_from_bson_task'.") path, ok = QFileDialog.getOpenFileName(self, "Choose a document collection .bson file!") if ok: self.disable_global_input() # noinspection PyUnresolvedReferences self.load_document_base_from_bson.emit(str(path))
def set_download_path(self): """设置下载路径""" dl_path = QFileDialog.getExistingDirectory(self, "选择文件下载保存文件夹", self.cwd) dl_path = os.path.normpath(dl_path) # windows backslash if dl_path == self.dl_path or dl_path == ".": return None self.dl_path_var.setText(dl_path) self.dl_path = dl_path
def save_statistics_to_json_task(self): logger.info("Execute task 'save_statistics_to_json_task'.") if self.statistics is not None: path = str(QFileDialog.getSaveFileName(self, "Choose where to save the statistics .json file!")[0]) if path != "": self.disable_global_input() # noinspection PyUnresolvedReferences self.save_statistics_to_json.emit(path, self.statistics)
def save_table_to_csv_task(self): logger.info("Execute task 'save_table_to_csv_task'.") if self.document_base is not None: path = str(QFileDialog.getSaveFileName(self, "Choose where to save the table .csv file!")[0]) if path != "": self.disable_global_input() # noinspection PyUnresolvedReferences self.save_table_to_csv.emit(path, self.document_base)
def open_path_selection_dialog(self) -> None: file_path: str = str(pathlib.Path(__file__).parent.resolve()) file_path = file_path[:file_path.find('src') - 1] self.header_output_path_input.setText( QFileDialog.getExistingDirectory( self, "Open Directory", file_path, QFileDialog.Option.ShowDirsOnly | QFileDialog.Option.DontResolveSymlinks))
def save_document_base_to_bson_task(self): logger.info("Execute task 'save_document_base_to_bson_task'.") if self.document_base is not None: path, ok = QFileDialog.getSaveFileName(self, "Choose where to save the document collection .bson file!") if ok: self.disable_global_input() # noinspection PyUnresolvedReferences self.save_document_base_to_bson.emit(str(path), self.document_base)
def save_matching_phase_to_config_task(self): logger.info("Execute task 'save_matching_phase_to_config_task'.") if self.matching_phase is not None: path = str(QFileDialog.getSaveFileName(self, "Choose where to save the configuration .json file!")[0]) if path != "": self.disable_global_input() # noinspection PyUnresolvedReferences self.save_matching_phase_to_config.emit(path, self.matching_phase)
def getFileDirectory(self, filename): dirlist = QFileDialog.getExistingDirectory() if filename == 'path1files': self.lineEdit.setText(dirlist) else: self.lineEdit_2.setText(dirlist) with open(filename + '.ini', 'w') as f: f.write(dirlist) print(dirlist)
def slot_choose_folder(self): dir_choose = QFileDialog.getExistingDirectory(self, "选择文件夹", self.cwd) # 起始路径 if dir_choose == "": return self.selected = dir_choose self.choose_folder.setText(self.selected) self.status.setText("") self.cwd = os.path.dirname(dir_choose)
def slot_btn_chooseDir(self): dir_choose = QFileDialog.getExistingDirectory(self, "选择文件夹", self.cwd) # 起始路径 if dir_choose == "": return if dir_choose not in self.selected: self.selected.append(dir_choose) self.cwd = os.path.dirname(dir_choose) self.show_selected()
def get_files(self): dialog = QFileDialog() dialog.setFileMode(QFileDialog.FileMode.AnyFile) dialog.setFilter(QDir.Filter.Files) if dialog.exec(): filenames = dialog.selectedFiles() f = open(filenames[0], 'r') with f: data = f.read() self.contents.setText(data)
def _load(self): '''A la hora de realizar la carga del fichero controlo si se produce un mensaje de error y lo muestro''' try: file = QFileDialog.getOpenFileName( self, 'Buscar Archivo', QDir.homePath(), "All Files (*);;Music Mp3 Files (*.mp3)") if file: print("Archivo seleccionado: ", file) except: print("Error en la carga de datos.")
def set_assister_path(): """设置辅助登录程序路径""" assister_path = QFileDialog.getOpenFileName(self, "选择辅助登录程序路径", self._cwd, "EXE Files (*.exe)") if not assister_path[0]: return None assister_path = os.path.normpath(assister_path[0]) # windows backslash if assister_path == self._cookie_assister: return None self.assister_ed.setText(assister_path) self._cookie_assister = assister_path
def getPassDirectory(self): # Сам выбор папки, да знаю, что немного косой, и можно было бы убрать из этого файла в другой self.inst = QtWidgets.QWidget() ui_drctry = Ui_drctryChoice() ui_drctry.setupUi(self.inst) dirlist = QFileDialog.getExistingDirectory(self) ui_drctry.lineEdit.setText(dirlist) with open('pathpass.ini', 'w') as f: f.write(dirlist) self.inst.show() print(dirlist)
def on_click(self): print('BrowseButton clicked {}'.format(self.input.text())) # self.input.setText('{} - Bar'.format(self.input.text())) folder = QFileDialog.getExistingDirectory( self, "Select Folder", "", QFileDialog.Options.ShowDirsOnly | QFileDialog.Options.DontUseNativeDialog) if folder: self.input.setText(folder) self.input.setStyleSheet("background-color:#ffff80") self.top.setEdited() self.input.setFocus()
def selectDataFile(self): filePath, _ = QFileDialog.getOpenFileName( self, "Open experiment (hdf5) file") self.experiment_file_name = os.path.split(filePath)[1].split('.')[0] self.experiment_file_directory = os.path.split(filePath)[0] if self.experiment_file_name != '': self.currentExperimentLabel.setText(self.experiment_file_name) self.initializeDataAnalysis() self.populateGroups() self.updateExistingRoiSetList()
def slot_btn_chooseMultiFile(self): files, _ = QFileDialog.getOpenFileNames(self, "选择多文件", self.cwd, "All Files (*)") if len(files) == 0: return for _file in files: if _file not in self.selected: if os.path.getsize(_file) <= self.max_size * 1048576: self.selected.append(_file) elif self.allow_big_file: self.selected.append(_file) self.show_selected()
def showDialog(self): home_dir = str(Path.home()) fname = QFileDialog.getOpenFileName(self, 'Open file', home_dir) if fname[0]: f = open(fname[0], 'r') with f: data = f.read() self.textEdit.setText(data)
def openDirectory(self): """Open a QFileDialog for selecting a local directory. Only display image and GIF files.""" directory = QFileDialog.getExistingDirectory( self, "Choose Directory", "", QFileDialog.Option.ShowDirsOnly ) # Specify the file mode to only select directories if directory: self.movie.setFileName(directory) # Check if image data is valid before playing if self.movie.isValid(): # Use setMovie() to set the label's contents as the selected GIF self.media_label.setMovie(self.movie) self.startMovie() # Call method to begin playing