python类getOpenFileName()的实例源码

coupleswapper_gui.py 文件源码 项目:FaceSwapper 作者: QuantumLiu 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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
spct_optionsdialog.py 文件源码 项目:specton 作者: somesortoferror 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def choosePathButton(self):
        sender = self.sender()
        if sender.objectName() == "pushButton_mediainfo_path":
            lineEdit = self.findChild(QLineEdit, "lineEdit_mediainfo_path")
            exe_name = "mediainfo"
        elif sender.objectName() == "pushButton_mp3guessenc_path":
            lineEdit = self.findChild(QLineEdit, "lineEdit_mp3guessenc_path")
            exe_name = "mp3guessenc"
        elif sender.objectName() == "pushButton_sox_path":
            lineEdit = self.findChild(QLineEdit, "lineEdit_sox_path")
            exe_name = "sox"
        elif sender.objectName() == "pushButton_ffprobe_path":
            lineEdit = self.findChild(QLineEdit, "lineEdit_ffprobe_path")
            exe_name = "ffprobe"
        elif sender.objectName() == "pushButton_aucdtect_path":
            lineEdit = self.findChild(QLineEdit, "lineEdit_aucdtect_path")
            exe_name = "aucdtect"
        if lineEdit is not None:
            path = lineEdit.text()
            file = str(QFileDialog.getOpenFileName(parent=self, caption=self.tr("Browse to")+" {} ".format(exe_name)+self.tr("executable file"),
                                                   directory=path)[0])
            if not file == "":
                lineEdit.setText(file)
flash_dialog.py 文件源码 项目:uPyLoader 作者: BetaRavener 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _pick_firmware(self):
        firmware_dir = None
        if Settings().last_firmware_directory:
            firmware_dir = Settings().last_firmware_directory

        p = QFileDialog.getOpenFileName(parent=self, caption="Select python executable",
                                        directory=firmware_dir, filter="*.bin")
        path = p[0]
        if path:
            self.firmwarePathEdit.setText(path)
            Settings().last_firmware_directory = "/".join(path.split("/")[0:-1])
reading_CSV.py 文件源码 项目:VIRTUAL-PHONE 作者: SumanKanrar-IEM 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def open_sheet(self):
        self.check_change = False
        path = QFileDialog.getOpenFileName(self, 'Open CSV', os.getenv('HOME'), 'CSV(*.csv)')
        if path[0] != '':
            with open(path[0], newline='') as csv_file:
                self.setRowCount(0)
                self.setColumnCount(10)
                my_file = csv.reader(csv_file, delimiter=',', quotechar='|')
                for row_data in my_file:
                    row = self.rowCount()
                    self.insertRow(row)
                    if len(row_data) > 10:
                        self.setColumnCount(len(row_data))
                    for column, stuff in enumerate(row_data):
                        item = QTableWidgetItem(stuff)
                        self.setItem(row, column, item)
        self.check_change = True
Writing_CSV.py 文件源码 项目:VIRTUAL-PHONE 作者: SumanKanrar-IEM 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def open_sheet(self):
        self.check_change = False
        path = QFileDialog.getOpenFileName(self, 'Open CSV', os.getenv('HOME'), 'CSV(*.csv)')
        if path[0] != '':
            with open(path[0], newline='') as csv_file:
                self.setRowCount(0)
                self.setColumnCount(10)
                my_file = csv.reader(csv_file, dialect='excel')
                for row_data in my_file:
                    row = self.rowCount()
                    self.insertRow(row)
                    if len(row_data) > 10:
                        self.setColumnCount(len(row_data))
                    for column, stuff in enumerate(row_data):
                        item = QTableWidgetItem(stuff)
                        self.setItem(row, column, item)
        self.check_change = True
refnodesets_widget.py 文件源码 项目:opcua-modeler 作者: FreeOpcUa 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def add_nodeset(self):
        path, ok = QFileDialog.getOpenFileName(self.view, caption="Import OPC UA XML Node Set", filter="XML Files (*.xml *.XML)", directory=".")
        if not ok:
            return None
        name = os.path.basename(path)
        if name in self.nodesets:
            return
        try:
            self.server_mgr.import_xml(path)
        except Exception as ex:
            self.error.emit(ex)
            raise

        item = QStandardItem(name)
        self.model.appendRow([item])
        self.nodesets.append(name)
        self.view.expandAll()
        self.nodeset_added.emit(path)
simpledommodel.py 文件源码 项目:Mac-Python-3.X 作者: L1nwatch 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def openFile(self):
        filePath, _ = QFileDialog.getOpenFileName(self, "Open File",
                self.xmlPath, "XML files (*.xml);;HTML files (*.html);;"
                "SVG files (*.svg);;User Interface files (*.ui)")

        if filePath:
            f = QFile(filePath)
            if f.open(QIODevice.ReadOnly):
                document = QDomDocument()
                if document.setContent(f):
                    newModel = DomModel(document, self)
                    self.view.setModel(newModel)
                    self.model = newModel
                    self.xmlPath = filePath

                f.close()
simpledommodel.py 文件源码 项目:examples 作者: pyqt 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def openFile(self):
        filePath, _ = QFileDialog.getOpenFileName(self, "Open File",
                self.xmlPath, "XML files (*.xml);;HTML files (*.html);;"
                "SVG files (*.svg);;User Interface files (*.ui)")

        if filePath:
            f = QFile(filePath)
            if f.open(QIODevice.ReadOnly):
                document = QDomDocument()
                if document.setContent(f):
                    newModel = DomModel(document, self)
                    self.view.setModel(newModel)
                    self.model = newModel
                    self.xmlPath = filePath

                f.close()
run_gui.py 文件源码 项目:ClassifyHub 作者: Top-Ranger 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def get_file_content(self):
        filename = QFileDialog.getOpenFileName(None, 'Open file')[0]
        if filename is '':
            return ''
        try:
            with open(filename, 'r') as file:
                try:
                    return str(file.read())
                except Exception as e:
                    QMessageBox.warning(None, 'Can not open file', 'Can not open file {}:\n{}'.format(filename, e))
                    return ''
        except IOError:
            return ''

    ##
    # \brief Returns the remaining rate limit
    #
    # Returns -1 if an error occurred. This request do not xount against the rate limit.
    #
    # \return Rate limit or -1 if error occurred
finPlateMain.py 文件源码 项目:Osdag 作者: osdag-admin 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def getLogoFilePath(self, lblwidget):

        self.ui.lbl_browse.clear()
        filename, _ = QFileDialog.getOpenFileName(
            self, 'Open File', " ../../",
            'Images (*.png *.svg*.jpg)',
            None, QFileDialog.DontUseNativeDialog)
        flag = True
        if filename == '':
            flag = False
            return flag
        else:
            base = os.path.basename(str(filename))
            lblwidget.setText(base)
            self.desired_location(filename)

        return str(filename)
simpledommodel.py 文件源码 项目:pyqt5-example 作者: guinslym 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def openFile(self):
        filePath, _ = QFileDialog.getOpenFileName(self, "Open File",
                self.xmlPath, "XML files (*.xml);;HTML files (*.html);;"
                "SVG files (*.svg);;User Interface files (*.ui)")

        if filePath:
            f = QFile(filePath)
            if f.open(QIODevice.ReadOnly):
                document = QDomDocument()
                if document.setContent(f):
                    newModel = DomModel(document, self)
                    self.view.setModel(newModel)
                    self.model = newModel
                    self.xmlPath = filePath

                f.close()
mainwindow.py 文件源码 项目:persepolis 作者: persepolisdm 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def importText(self, item):
        # get file path
        f_path, filters = QFileDialog.getOpenFileName(
            self, 'Select the text file that contains links')

        # if path is correct:
        if os.path.isfile(str(f_path)):
            # create a text_queue_window for getting information.
            text_queue_window = TextQueue(
                self, f_path, self.queueCallback, self.persepolis_setting)

            self.text_queue_window_list.append(text_queue_window)
            self.text_queue_window_list[len(
                self.text_queue_window_list) - 1].show()



# callback of text_queue_window and plugin_queue_window.AboutWindowi
# See importText and pluginQueue method for more information.
GUI.py 文件源码 项目:coliform-project 作者: uprm-research-resto 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def importImageThread(self):
        self.statusbar = 'Importing Image...'
        self.image = QFileDialog.getOpenFileName(self, 'Choose Image', os.sep.join((os.path.expanduser('~'), 'Desktop')),
                                                 'Image Files (*.png *.jpg *.jpeg)')
        importThread = threading.Thread(target=self.importImage)
        importThread.start()
GUIAssist.py 文件源码 项目:a-cadmci 作者: florez87 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def openFileTrain(self):
        """
        Opens a file dialog to select the file for training.

        Parameters
        ----------
        None

        Return
        ----------
        None
        """
        self.path_train, _ = QFileDialog.getOpenFileName(self.train, "Select Database File", "", "All files (*.*)")
GUIAssist.py 文件源码 项目:a-cadmci 作者: florez87 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def openFileValidate(self):
        """
        Opens a file dialog to select the file for validation.

        Parameters
        ----------
        None

        Return
        ----------
        None
        """
        self.path_validate, _ = QFileDialog.getOpenFileName(self.validate, "Select Database File", "", "All files (*.*)")
flash_dialog.py 文件源码 项目:uPyLoader 作者: BetaRavener 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _pick_python(self):
        p = QFileDialog.getOpenFileName(parent=self, caption="Select python executable")
        path = p[0]
        if path:
            self.pythonPathEdit.setText(path)
            Settings().python_flash_executable = path
MainWindowController.py 文件源码 项目:Qyoutube-dl 作者: lzambella 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def on_load_batch_file_pressed(self):
            file = QFileDialog.getOpenFileName()
            with open(file[0]) as f:
                lines = f.read().splitlines()
            self.batch_load(lines)
filedialogs.py 文件源码 项目:VIRTUAL-PHONE 作者: SumanKanrar-IEM 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def openFileNameDialog(self):    
        options = QFileDialog.Options()
        options |= QFileDialog.DontUseNativeDialog
        fileName, _ = QFileDialog.getOpenFileName(self,"QFileDialog.getOpenFileName()", "","All Files (*);;Python Files (*.py)", options=options)
        if fileName:
            print(fileName)
Notepad_menubar.py 文件源码 项目:VIRTUAL-PHONE 作者: SumanKanrar-IEM 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def open_text(self):
        filename = QFileDialog.getOpenFileName(self, 'Open File', os.getenv('HOME'))
        with open(filename[0], 'r') as f:
            file_text = f.read()
            self.text.setText(file_text)
TextEditor_QFileDialog.py 文件源码 项目:VIRTUAL-PHONE 作者: SumanKanrar-IEM 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def open_text(self):
        filename = QFileDialog.getOpenFileName(self, 'Open File', os.getenv('HOME'))
        with open(filename[0], 'r') as f:
            file_text = f.read()
            self.text.setText(file_text)
Notepad.py 文件源码 项目:VIRTUAL-PHONE 作者: SumanKanrar-IEM 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def open_text(self):
        filename = QFileDialog.getOpenFileName(self, 'Open File', os.getenv('HOME'))
        with open(filename[0], 'r') as f:
            file_text = f.read()
            self.text.setText(file_text)
addcontact_app.py 文件源码 项目:VIRTUAL-PHONE 作者: SumanKanrar-IEM 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def openFileNameDialog(self):
        print("set icon clicked")
        options = QFileDialog.Options()
        options |= QFileDialog.DontUseNativeDialog
        fileName, _ = QFileDialog.getOpenFileName(self, "Choose Contact Icon", "", "Image Files (*.jpg *.png)", options=options)
        if fileName:
            print(fileName)
            pixmap = QtGui.QPixmap(fileName)
            self.contact_icon.setPixmap(pixmap)
            self.contact_icon.setScaledContents(True)
            # pixmap2 = self.contact_icon.pixmap()
            # print(pixmap2)
addcontact_app.py 文件源码 项目:VIRTUAL-PHONE 作者: SumanKanrar-IEM 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def openFileNameDialog(self):
        print("set icon clicked")
        options = QFileDialog.Options()
        options |= QFileDialog.DontUseNativeDialog
        fileName, _ = QFileDialog.getOpenFileName(self, "Choose Contact Icon", "", "Image Files (*.jpg *.png)", options=options)
        if fileName:
            print(fileName)
            pixmap = QtGui.QPixmap(fileName)
            self.contact_icon.setPixmap(pixmap)
            self.contact_icon.setScaledContents(True)
            # pixmap2 = self.contact_icon.pixmap()
            # print(pixmap2)
dxf2gcode.py 文件源码 项目:dxf2gcode 作者: cnc-club 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def OpenFileDialog(self, title):
        self.filename, _ = getOpenFileName(self,
                                           title,
                                           g.config.vars.Paths['import_dir'],
                                           self.tr("All supported files (*.dxf *.ps *.pdf *%s);;"
                                                   "DXF files (*.dxf);;"
                                                   "PS files (*.ps);;"
                                                   "PDF files (*.pdf);;"
                                                   "Project files (*%s);;"
                                                   "All types (*.*)") % (c.PROJECT_EXTENSION, c.PROJECT_EXTENSION))

        # If there is something to load then call the load function callback
        if self.filename:
            self.filename = file_str(self.filename)
            logger.info(self.tr("File: %s selected") % self.filename)
probe.py 文件源码 项目:hacked_cnc 作者: hackerspace 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def load_probe_data_dialog(self):
        fname, mask = QFileDialog.getOpenFileName(None, "Load probe data", "",
            "Log data (*.txt *.log);;All files (*.*)")

        if fname:
            self.load_probe_data(fname)
CRIkitUI.py 文件源码 项目:CRIkit2 作者: CoherentRamanNIST 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def fileOpenDLMNIST(self):
        """
        Open and load DLM File
        """

        # Get data and load into CRI_HSI class
        # This will need to change to accomodate multiple-file selection
        filename_header,_ = _QFileDialog.getOpenFileName(self, 'Open Header File',
                                                         './', 'All Files (*.*)')


        if filename_header != '':
            self.path = _os.path.dirname(filename_header) + '/'
            filename_data,_ = _QFileDialog.getOpenFileName(self, 'Open Data File',
                                                           self.path,
                                                           'All Files (*.*)')

            if filename_data != '':
                self.path = _os.path.dirname(filename_data) + '/'
                self.filename = filename_data.split(_os.path.dirname(filename_data))[1][1::]
                self.filename_header = filename_header

                success = io_nist_dlm(self.path, self.filename_header,
                                      self.filename,
                                      self.hsi)
                self.fileOpenSuccess(success)
CRIkitUI.py 文件源码 项目:CRIkit2 作者: CoherentRamanNIST 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def loadDarkDLM(self):
        """
        Open DLM file and load dark spectrum(a)
        """


        filename,_ = _QFileDialog.getOpenFileName(self, 'Open Dark File',
                                                  self.path,
                                                  'All Files (*.*)')
        if filename != '':
            filename = filename.split(_os.path.dirname(filename))[1][1::]


            # Spectra first
            self.dark = Spectra()
            success = io_nist_dlm(self.path, self.filename_header, filename,
                                  self.dark)
            if not success: # Maybe Spectrum
                self.dark = Spectrum()
                success = io_nist_dlm(self.path, self.filename_header, filename,
                                      self.dark)
#            print('Success: {}'.format(success))

            if success:
                if self.dark.shape[-1] == self.hsi.freq.size:
                    self.ui.actionDarkSubtract.setEnabled(True)
                    self.ui.actionDarkSpectrum.setEnabled(True)
                else:
                    self.dark = Spectra()
                    print('Dark was the wrong shape')
            else:
                self.dark = Spectra()
                self.ui.actionDarkSubtract.setEnabled(False)
                self.ui.actionDarkSpectrum.setEnabled(False)
CRIkitUI.py 文件源码 项目:CRIkit2 作者: CoherentRamanNIST 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def loadNRBDLM(self):
        """
        Open DLM file and load NRB spectrum(a)
        """


        filename, _ = _QFileDialog.getOpenFileName(self, 'Open NRB File',
                                                   self.path,
                                                   'All Files (*.*)')
        if filename != '':
            filename = filename.split(_os.path.dirname(filename))[1][1::]


            # Spectra first
            self.nrb = Spectra()
            success = io_nist_dlm(self.path, self.filename_header, filename,
                                  self.nrb)
            if not success: # Maybe Spectrum
                self.nrb = Spectrum()
                success = io_nist_dlm(self.path, self.filename_header, filename,
                                      self.nrb)
            print('Success: {}'.format(success))

            if success:
                if self.dark.shape[-1] == self.hsi.freq.size:
                    self.ui.actionKramersKronig.setEnabled(True)
                    self.ui.actionKKSpeedTest.setEnabled(True)
                    self.ui.actionNRBSpectrum.setEnabled(True)
                    self.ui.actionDeNoiseNRB.setEnabled(True)
                else:
                    self.nrb = Spectra()
                    print('NRB was the wrong shape')
            else:
                self.nrb = Spectra()
                self.ui.actionKramersKronig.setEnabled(False)
                self.ui.actionKKSpeedTest.setEnabled(False)
                self.ui.actionNRBSpectrum.setEnabled(False)
                self.ui.actionDeNoiseNRB.setEnabled(False)
utils.py 文件源码 项目:TextStageProcessor 作者: mhyhre 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def getFilenameFromUserSelection(file_types="Any Files (*.*)", path = ''):
    filenames, _ = QFileDialog.getOpenFileName(None, "??????? ????", path, file_types, None)
    if (len(filenames) > 0):
        return filenames
    else:
        return None
file_dialog.py 文件源码 项目:pysport 作者: sportorg 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def get_open_file_name(caption='', filter_text=''):
    result = QFileDialog.getOpenFileName(None, caption, get_default_dir(), filter_text)[0]
    if result:
        set_default_dir(os.path.dirname(os.path.abspath(result)))
    return result


问题


面经


文章

微信
公众号

扫码关注公众号