Python PyQt5.QtWidgets.QFileDialog.getOpenFileName() Examples

The following are 30 code examples of PyQt5.QtWidgets.QFileDialog.getOpenFileName(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtWidgets.QFileDialog , or try the search function .
Example #1
Source File: fileManager.py    From openMotor with GNU General Public License v3.0 7 votes vote down vote up
def load(self, path=None):
        if self.unsavedCheck():
            if path is None:
                path = QFileDialog.getOpenFileName(None, 'Load motor', '', 'Motor Files (*.ric)')[0]
            if path != '': # If they cancel the dialog, path will be an empty string
                try:
                    res = loadFile(path, fileTypes.MOTOR)
                    if res is not None:
                        motor = motorlib.motor.Motor()
                        motor.applyDict(res)
                        self.startFromMotor(motor, path)
                        return True
                except Exception as exc:
                    self.app.outputException(exc, "An error occurred while loading the file: ")

        return False # If no file is loaded, return false

    # Return the recent end of the motor history 
Example #2
Source File: Ui_MakupGUI.py    From AIMakeup with Apache License 2.0 6 votes vote down vote up
def _open_img(self):
        '''
        打开图片
        '''
        self.path_img,_=QFileDialog.getOpenFileName(self.centralWidget,'打开图片文件','./','Image Files(*.png *.jpg *.bmp)')
        if self.path_img and os.path.exists(self.path_img):
            print(self.path_img)
            self.im_bgr,self.temp_bgr,self.faces=self.mu.read_and_mark(self.path_img)
            self.im_ori,self.previous_bgr=self.im_bgr.copy(),self.im_bgr.copy()
            self._set_statu(self.bg_edit,True)
            self._set_statu(self.bg_op,True)
            self._set_statu(self.bg_result,True)
            self._set_statu(self.sls,True)
            self._set_img()
        else:
            QMessageBox.warning(self.centralWidget,'无效路径','无效路径,请重新选择!') 
Example #3
Source File: seistomopy_gui.py    From SeisTomoPy_V3 with GNU General Public License v3.0 6 votes vote down vote up
def on_loadfile_spec_released(self):
        pwd = os.getcwd()
        self.spectre_file, _ = (QFileDialog.getOpenFileName(
            self, "Choose *.xyz", pwd,"Map file (*.xyz);;"))
        if not self.spectre_file:
            return
        if self.spectre_file.endswith('.xyz'):
            self.ui.label_31.setText(os.path.basename(self.spectre_file))
            filename6 = DIR2 + '/input_files/map_file.xyz'
            shutil.copy2(self.spectre_file,filename6)
        else:
            raise IOError('unknown file type *.%s' %
                          self.spectre_file.split('.')[-1])

################################################################
#                      TOOLS FOR CORRELATION
################################################################ 
Example #4
Source File: seistomopy_gui.py    From SeisTomoPy_V3 with GNU General Public License v3.0 6 votes vote down vote up
def on_loadfile_model_released(self):
        pwd = os.getcwd()
        self.corr_file6, _ = (QFileDialog.getOpenFileName(
            self, "Choose *.nd", pwd,"Model file (*.nd);;"))
        if not self.corr_file6:
            return
        if self.corr_file6.endswith('.nd'):
            self.ui.label_58.setText(os.path.basename(self.corr_file6))
            filename7 = DIR2 + '/input_files/model_file.nd'
            shutil.copy2(self.corr_file6,filename7)
        else:
            raise IOError('unknown file type *.%s' %
                          self.corr_file6.split('.')[-1])

################################################################
#                      TOOLS FOR TIME
################################################################ 
Example #5
Source File: gui.py    From PUBGIS with GNU General Public License v3.0 5 votes vote down vote up
def _select_video_file(self):
        file_name, _ = QFileDialog.getOpenFileName(directory=self.last_video_file_dir,
                                                   filter="Videos (*.mp4)")
        self._set_video_file(file_name) 
Example #6
Source File: main.py    From fssim with MIT License 5 votes vote down vote up
def handle_input_snap(self):
        if not self._topics_for_snpshot_found:
            name = QFileDialog.getOpenFileName(self._widget, 'Load from Bag')
            self._widget.comboBox_snap_topics.clear()

            found_topics = self._cones_view.snapshots.get_topic_names(name[0], PointCloud2)
            self._widget.comboBox_snap_topics.addItems(found_topics)
            self._topics_for_snpshot_found = True 
Example #7
Source File: main.py    From xqemu-manager with GNU General Public License v2.0 5 votes vote down vote up
def setSaveFileName(self, obj):
		options = QFileDialog.Options()
		fileName, _ = QFileDialog.getOpenFileName(self,
				"Select File",
				obj.text(),
				"All Files (*)", options=options)
		if fileName:
			obj.setText(fileName) 
Example #8
Source File: main_win.py    From BlindWatermark with GNU General Public License v3.0 5 votes vote down vote up
def on_pushButton_clicked(self):
        """
        Slot documentation goes here.
        """
        my_file_path,_ = QFileDialog.getOpenFileName(self, '导入图片', self.my_bwm_parameter.get('work_path','./'))
        if my_file_path:
            self.my_bwm_parameter['ori_img'] = my_file_path
            self.label_4.setText(my_file_path.split('/')[-1]) 
Example #9
Source File: main_win.py    From BlindWatermark with GNU General Public License v3.0 5 votes vote down vote up
def on_pushButton_2_clicked(self):
        """
        Slot documentation goes here.
        """
        my_file_path,_ = QFileDialog.getOpenFileName(self, '导入水印', self.my_bwm_parameter.get('work_path','./'))
        if my_file_path:
            self.my_bwm_parameter['wm'] = my_file_path
            self.label_5.setText(my_file_path.split('/')[-1]) 
Example #10
Source File: seistomopy_gui.py    From SeisTomoPy_V3 with GNU General Public License v3.0 5 votes vote down vote up
def on_loadfile1_corr_released(self):
        pwd = os.getcwd()
        self.corr_file1, _ = (QFileDialog.getOpenFileName(
            self, "Choose *.xyz", pwd,"Map file (*.xyz);;"))
        if not self.corr_file1:
            return
        if self.corr_file1.endswith('.xyz'):
            self.ui.label_33.setText(os.path.basename(self.corr_file1))
            filename6 = DIR2 + '/input_files/map_file1.xyz'
            shutil.copy2(self.corr_file1,filename6)
        else:
            raise IOError('unknown file type *.%s' %
                          self.corr_file1.split('.')[-1]) 
Example #11
Source File: seistomopy_gui.py    From SeisTomoPy_V3 with GNU General Public License v3.0 5 votes vote down vote up
def on_loadfile_path_released(self):
        pwd = os.getcwd()
        self.corr_file3, _ = (QFileDialog.getOpenFileName(
            self, "Choose *.sph", pwd,"Cross-section file (*.sph);;"))
        if not self.corr_file3:
            return
        if self.corr_file3.endswith('.sph'):
            self.ui.label_45.setText(os.path.basename(self.corr_file3))
            filename7 = DIR2 + '/input_files/cross_section_path.xyz'
            shutil.copy2(self.corr_file3,filename7)
        else:
            raise IOError('unknown file type *.%s' %
                          self.corr_file3.split('.')[-1]) 
Example #12
Source File: seistomopy_gui.py    From SeisTomoPy_V3 with GNU General Public License v3.0 5 votes vote down vote up
def on_loadfile_eq_released(self):
        pwd = os.getcwd()
        self.corr_file4, _ = (QFileDialog.getOpenFileName(
            self, "Choose *.xy", pwd,"Event file (*.xy);;"))
        if not self.corr_file4:
            return
        if self.corr_file4.endswith('.xy'):
            self.ui.label_48.setText(os.path.basename(self.corr_file4))
            filename7 = DIR2 + '/input_files/event_file_path.xy'
            shutil.copy2(self.corr_file4,filename7)
        else:
            raise IOError('unknown file type *.%s' %
                          self.corr_file4.split('.')[-1]) 
Example #13
Source File: seistomopy_gui.py    From SeisTomoPy_V3 with GNU General Public License v3.0 5 votes vote down vote up
def on_loadfile_st_released(self):
        pwd = os.getcwd()
        self.corr_file5, _ = (QFileDialog.getOpenFileName(
            self, "Choose *.xy", pwd,"Station file (*.xy);;"))
        if not self.corr_file5:
            return
        if self.corr_file5.endswith('.xy'):
            self.ui.label_49.setText(os.path.basename(self.corr_file5))
            filename7 = DIR2 + '/input_files/station_file_path.xy'
            shutil.copy2(self.corr_file5,filename7)
        else:
            raise IOError('unknown file type *.%s' %
                          self.corr_file5.split('.')[-1]) 
Example #14
Source File: seistomopy_gui.py    From SeisTomoPy_V3 with GNU General Public License v3.0 5 votes vote down vote up
def on_loadfile_time_released(self):
        pwd = os.getcwd()
        self.corr_file6, _ = (QFileDialog.getOpenFileName(
            self, "Choose *.xy", pwd,"Data file (*.xy);;"))
        if not self.corr_file6:
            return
        if self.corr_file6.endswith('.xy'):
            self.ui.label_115.setText(os.path.basename(self.corr_file6))
            filename7 = DIR2 + 'output_files_time/timepy_data_file.xy'
            shutil.copy2(self.corr_file6,filename7)
        else:
            raise IOError('unknown file type *.%s' %
                          self.corr_file6.split('.')[-1]) 
Example #15
Source File: Ui_MakupGUI.py    From AIMakeup with Apache License 2.0 5 votes vote down vote up
def __init__(self, MainWindow):
        self.window=MainWindow
        self._setupUi()
        #控件分组
        self.bg_edit=[self.bt_brightening,self.bt_whitening,self.bt_sharpen,self.bt_smooth]
        self.bg_op=[self.bt_confirm,self.bt_cancel,self.bt_reset]
        self.bg_result=[self.bt_view_compare,self.bt_save,self.bt_save_compare]
        self.sls=[self.sl_brightening,self.sl_sharpen,self.sl_whitening,self.sl_smooth]
        #用于显示图片的标签
        self.label=QtWidgets.QLabel(self.window)
        self.sa.setWidget(self.label)
        #批量设置状态
        self._set_statu(self.bg_edit,False)
        self._set_statu(self.bg_op,False)
        self._set_statu(self.bg_result,False)
        self._set_statu(self.sls,False)
        #导入dlib模型文件
        if os.path.exists("./data/shape_predictor_68_face_landmarks.dat"):
            self.path_predictor=os.path.abspath("./data/shape_predictor_68_face_landmarks.dat")
        else:
            QMessageBox.warning(self.centralWidget,'警告','默认的dlib模型文件路径不存在,请指定文件位置。\
                                \n或从http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2下载')
            self.path_predictor,_=QFileDialog.getOpenFileName(self.centralWidget,'选择dlib模型文件','./','Data Files(*.dat)')
        #实例化化妆器
        self.mu=Makeup(self.path_predictor)
        
        self.path_img=''
        self._set_connect() 
Example #16
Source File: qt.py    From pywebview with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def on_file_dialog(self, dialog_type, directory, allow_multiple, save_filename, file_filter):
        if dialog_type == FOLDER_DIALOG:
            self._file_name = QFileDialog.getExistingDirectory(self, localization['linux.openFolder'], options=QFileDialog.ShowDirsOnly)
        elif dialog_type == OPEN_DIALOG:
            if allow_multiple:
                self._file_name = QFileDialog.getOpenFileNames(self, localization['linux.openFiles'], directory, file_filter)
            else:
                self._file_name = QFileDialog.getOpenFileName(self, localization['linux.openFile'], directory, file_filter)
        elif dialog_type == SAVE_DIALOG:
            if directory:
                save_filename = os.path.join(str(directory), str(save_filename))

            self._file_name = QFileDialog.getSaveFileName(self, localization['global.saveFile'], save_filename)

        self._file_name_semaphore.release() 
Example #17
Source File: converter.py    From openMotor with GNU General Public License v3.0 5 votes vote down vote up
def showFileSelector(self):
        """Open a dialog to pick the file to load"""
        if self.manager.unsavedCheck():
            path = QFileDialog.getOpenFileName(None, 'Import ' + self.name, '', self.getFileTypeString())[0]
            if path != '':
                return path
        return None 
Example #18
Source File: MCUProg.py    From DMCUProg with MIT License 5 votes vote down vote up
def on_btnHEX_clicked(self):
        hexpath, filter = QFileDialog.getOpenFileName(caption='程序文件路径', filter='程序文件 (*.bin *.hex)', directory=self.cmbHEX.currentText(),)
        if hexpath:
            self.cmbHEX.insertItem(0, hexpath)
            self.cmbHEX.setCurrentIndex(0) 
Example #19
Source File: main.py    From fssim with MIT License 5 votes vote down vote up
def handle_load_track(self, str):
        name = QFileDialog.getOpenFileName(self._widget, 'Import from File',os.environ['HOME'],"*.bag")
        outside = self._widget.lineEdit_track_topic_outside.text()
        inside = self._widget.lineEdit_track_topic_inside.text()
        center = self._widget.lineEdit_track_topic_center.text()
        self._cones_view.handle_btn_import(name[0],outside,inside,center) 
Example #20
Source File: main_win.py    From BlindWatermark with GNU General Public License v3.0 5 votes vote down vote up
def on_pushButton_9_clicked(self):
        """
        读取受到攻击的图片
        """
        file_path,_ = QFileDialog.getOpenFileName(self, '读取受到攻击的图片', self.my_bwm_parameter.get('work_path','./'))
        if file_path:
            self.my_recovery_parameter['attacked_img'] = file_path 
Example #21
Source File: HFView.py    From JHFView with MIT License 5 votes vote down vote up
def on_btnDis_clicked(self):
        dispath, filter = QFileDialog.getOpenFileName(caption='反汇编文件路径', filter='disassembler (*.dis *.asm *.txt)', directory=self.cmbDis.currentText())
        if dispath != '':
            self.cmbDis.insertItem(0, dispath)
            self.cmbDis.setCurrentIndex(0) 
Example #22
Source File: HFView.py    From JHFView with MIT License 5 votes vote down vote up
def on_btnDLL_clicked(self):
        dllpath, filter = QFileDialog.getOpenFileName(caption='JLink_x64.dll路径', filter='动态链接库文件 (*.dll)', directory=self.linDLL.text())
        if dllpath != '':
            self.linDLL.setText(dllpath) 
Example #23
Source File: main.py    From BeautyCamera with MIT License 5 votes vote down vote up
def open_file(self):
        fname = QFileDialog.getOpenFileName(None, '打开文件', './', ("Images (*.png *.xpm *.jpg)"))
        if fname[0]:
            img_cv = cv2.imdecode(np.fromfile(fname[0], dtype=np.uint8), -1)  # 注意这里读取的是RGB空间的
            self.raw_image = img_cv
            self.last_image = img_cv
            self.current_img = img_cv
            self.show_image()
            self.show_histogram()
            self.imgskin = np.zeros(self.raw_image.shape)
        self.intial_value()

# 恢复图片 
Example #24
Source File: TrackerViewerAux.py    From tierpsy-tracker with MIT License 5 votes vote down vote up
def getSkelFile(self):
        selected_file, _ = QFileDialog.getOpenFileName(
            self, 'Select file with the worm skeletons', self.results_dir, "Skeletons files (*_skeletons.hdf5);; All files (*)")

        if not Path(selected_file).exists():
            return

        self.updateSkelFile(selected_file) 
Example #25
Source File: BatchProcessing.py    From tierpsy-tracker with MIT License 5 votes vote down vote up
def getParamFile(self):
        param_file, _ = QFileDialog.getOpenFileName(
            self, "Find parameters file", '', "JSON files (*.json);; All (*)")
        if param_file:
            self.updateParamFile(param_file) 
Example #26
Source File: BatchProcessing.py    From tierpsy-tracker with MIT License 5 votes vote down vote up
def getTxtFileList(self):
        videos_list, _ = QFileDialog.getOpenFileName(
            self, "Select a text file with a list of files to be analyzed.", '', "Text file (*.txt);;All files (*)")
        if os.path.isfile(videos_list):
            self.updateTxtFileList(videos_list) 
Example #27
Source File: coupleswapper_gui.py    From FaceSwapper with Apache License 2.0 5 votes vote down vote up
def load_image(self):
        '''
        加载原图
        '''
        try:
            im_path,_=QFileDialog.getOpenFileName(self,'打开图片文件','./','Image Files(*.png *.jpg *.bmp)')
            if not os.path.exists(im_path):
                return
            self.im_path=im_path
            self.statu_text.append('打开图片文件:'+self.im_path)
            if not self.swapper:
                self.swapper=Coupleswapper([self.im_path])
            elif not self.im_path== self.cur_im_path:
                self.swapper.load_heads([self.im_path])
            self.img_ori=self.swapper.heads[os.path.split(self.im_path)[-1]][0]
            cv2.imshow('Origin',self.img_ori)
        except (TooManyFaces,NoFace):
            self.statu_text.append(traceback.format_exc()+'\n人脸定位失败,请重新选择!保证照片中有两张可识别的人脸。')
            return 
Example #28
Source File: util.py    From guppy-proxy with MIT License 5 votes vote down vote up
def open_dialog(parent, filter_string="Any File (*)", default_dir=None):
    fname, _ = QFileDialog.getOpenFileName(parent, "Save File", default_dialog_dir(), filter_string)
    if not fname:
        return None
    set_default_dialog_dir(os.path.abspath(fname))
    return fname 
Example #29
Source File: project.py    From pyNMS with GNU General Public License v3.0 5 votes vote down vote up
def yaml_import(self, filepath=None):
        if not filepath:
            filepath = QFileDialog.getOpenFileName(
                                            self, 
                                            'Import project', 
                                            'Choose a project to import'
                                            )[0]
                                
        with open(filepath, 'r') as file:
            yaml_project = load(file)
            
            for subtype in self.import_order:
                if subtype not in yaml_project:
                    continue
                for obj, properties in yaml_project[subtype].items():
                    kwargs = {}
                    for property_name, value in properties.items():
                        value = self.network.objectizer(property_name, value)
                        kwargs[property_name] = value
                    if subtype in node_subtype:
                        if subtype == 'site':
                            self.site_view.network.nf(subtype=subtype, **kwargs)
                        else:

                            self.network_view.network.nf(subtype=subtype, **kwargs)
                    if subtype in link_subtype: 
                        self.network_view.network.lf(subtype=subtype, **kwargs)
                        
        self.network_view.refresh_display()
        self.network_view.move_to_geographical_coordinates() 
Example #30
Source File: demo_ui.py    From pymiere with GNU General Public License v3.0 5 votes vote down vote up
def open_func(self, *args):
        self.__active_sequence = None
        filepath = os.path.normpath(QFileDialog.getOpenFileName(caption="Choose a project to open...", directory=default_folder)[0])
        # if not filepath.endswith(".pproj"):
        #     raise ValueError("Given path was not a valid premiere pro document")
        pymiere.objects.app.openDocument(filepath)