當前位置: 首頁>>代碼示例>>Python>>正文


Python QFileDialog.getExistingDirectory方法代碼示例

本文整理匯總了Python中PyQt5.QtWidgets.QFileDialog.getExistingDirectory方法的典型用法代碼示例。如果您正苦於以下問題:Python QFileDialog.getExistingDirectory方法的具體用法?Python QFileDialog.getExistingDirectory怎麽用?Python QFileDialog.getExistingDirectory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtWidgets.QFileDialog的用法示例。


在下文中一共展示了QFileDialog.getExistingDirectory方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: on_saveoutput_corr_released

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getExistingDirectory [as 別名]
def on_saveoutput_corr_released(self):

        selected_directory8 = QFileDialog.getExistingDirectory()

        if not selected_directory8:
            return

        if os.path.isdir(str(selected_directory8) + '/output_corr'):

        	QMessageBox.critical(None, "Message", "This directory already exists in this directory")
        else:
            shutil.copytree(DIR2 + '/output_files_corr', str(selected_directory8) + '/output_corr')
            path = DIR2 + '/output_files_corr'
            dirs = os.listdir(path)
            os.chdir(DIR2 + '/output_files_corr')
            for i in range(len(dirs)):
                os.remove(dirs[i])
            os.chdir(DIR)

################################################################
#                         UPDATES
################################################################ 
開發者ID:stephaniedurand,項目名稱:SeisTomoPy_V3,代碼行數:24,代碼來源:seistomopy_gui.py

示例2: changeFolder

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getExistingDirectory [as 別名]
def changeFolder(self, button):
        # get download_path from lineEdit
        download_path = self.download_folder_lineEdit.text()

        # open select folder dialog
        fname = QFileDialog.getExistingDirectory(
            self, 'Select a directory', download_path)

        if fname:
            # Returns pathName with the '/' separators converted to separators that are appropriate for the underlying operating system.
            # On Windows, toNativeSeparators("c:/winnt/system32") returns
            # "c:\winnt\system32".
            fname = QDir.toNativeSeparators(fname)

        if os.path.isdir(fname):
            self.download_folder_lineEdit.setText(fname)

# enable when link_lineEdit is not empty and find size of file. 
開發者ID:persepolisdm,項目名稱:persepolis,代碼行數:20,代碼來源:addlink.py

示例3: on_saveoutput_spec_released

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getExistingDirectory [as 別名]
def on_saveoutput_spec_released(self):

        dep_spec = int(self.ui.depth_spec.value())

        selected_directory7 = QFileDialog.getExistingDirectory()

        if not selected_directory7:
            return

        if os.path.isdir(str(selected_directory7) + '/output_spectre_' + \
             str(dep_spec) + 'km'):
            QMessageBox.critical(None, "Message", "This directory already exists")
        else:
            shutil.copytree(DIR2 + '/output_files_spectre', str(selected_directory7) + '/output_spectre_' + \
             str(dep_spec) + 'km')

            path = DIR2 + "/output_files_spectre"
            dirs = os.listdir(path)
            os.chdir(DIR2 + '/output_files_spectre')
            for i in range(len(dirs)):
                os.remove(dirs[i])
            os.chdir(DIR) 
開發者ID:stephaniedurand,項目名稱:SeisTomoPy_V3,代碼行數:24,代碼來源:seistomopy_gui.py

示例4: show_file_dialog

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getExistingDirectory [as 別名]
def show_file_dialog(self):
        selected_dir = QFileDialog.getExistingDirectory(self, caption='Choose Directory', directory=os.getcwd())
        self.lineEdit_save_location.setText(selected_dir) 
開發者ID:XIAZY,項目名稱:DriveIt,代碼行數:5,代碼來源:driveit-gui.py

示例5: changeFolder

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getExistingDirectory [as 別名]
def changeFolder(self, button):
        fname = QFileDialog.getExistingDirectory(self, 'Open f', '/home')

        if fname:
            # Returns pathName with the '/' separators converted to separators that are appropriate for the underlying operating system.
            # On Windows, toNativeSeparators("c:/winnt/system32") returns
            # "c:\winnt\system32".
            fname = QDir.toNativeSeparators(fname)

        if os.path.isdir(fname):
            self.download_folder_lineEdit.setText(fname) 
開發者ID:persepolisdm,項目名稱:persepolis,代碼行數:13,代碼來源:properties.py

示例6: changeFolder

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getExistingDirectory [as 別名]
def changeFolder(self, button):
        fname = QFileDialog.getExistingDirectory(
            self, 'Select a directory', download_path)

        if fname:
            # Returns pathName with the '/' separators converted to separators that are appropriate for the underlying operating system.
            # On Windows, toNativeSeparators("c:/winnt/system32") returns
            # "c:\winnt\system32".
            fname = QDir.toNativeSeparators(fname)

        if os.path.isdir(fname):
            self.download_folder_lineEdit.setText(fname) 
開發者ID:persepolisdm,項目名稱:persepolis,代碼行數:14,代碼來源:browser_plugin_queue.py

示例7: downloadFolderPushButtonClicked

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getExistingDirectory [as 別名]
def downloadFolderPushButtonClicked(self, button):

        download_path = str(
            self.persepolis_setting.value('settings/download_path'))
        fname = QFileDialog.getExistingDirectory(
            self, 'Select a directory', download_path)

        if fname:
            # Returns pathName with the '/' separators converted to separators that are appropriate for the underlying operating system.
            # On Windows, toNativeSeparators("c:/winnt/system32") returns
            # "c:\winnt\system32".
            fname = QDir.toNativeSeparators(fname)
            self.download_folder_lineEdit.setText(fname)
            self.persepolis_setting.setValue(
                'settings/download_path', str(fname)) 
開發者ID:persepolisdm,項目名稱:persepolis,代碼行數:17,代碼來源:setting.py

示例8: tempDownloadPushButtonClicked

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getExistingDirectory [as 別名]
def tempDownloadPushButtonClicked(self, button):

        download_path_temp = str(
            self.persepolis_setting.value('settings/download_path_temp'))
        fname = QFileDialog.getExistingDirectory(
            self, 'Open f', download_path_temp)

        if fname:
            self.temp_download_lineEdit.setText(fname)
            self.persepolis_setting.setValue(
                'settings/download_path_temp', str(fname)) 
開發者ID:persepolisdm,項目名稱:persepolis,代碼行數:13,代碼來源:setting.py

示例9: b_define_matlib_dir

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getExistingDirectory [as 別名]
def b_define_matlib_dir(self):
        """
        b_define_matlib_dir open a dialog to select the matlib directory 
        """
        folder = QFileDialog.getExistingDirectory(self, "Select MatLib directory")
        if folder != self.matlib.ref_path and folder:
            self.le_matlib_path.setText(folder)
        GUI_logger.info("message") 
開發者ID:Eomys,項目名稱:pyleecan,代碼行數:10,代碼來源:WGuiOption.py

示例10: load

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getExistingDirectory [as 別名]
def load(self):
        """Load the material library

        Parameters
        ----------
        self :
            A DMatLib object

        Returns
        -------

        """

        load_path = str(
            QFileDialog.getExistingDirectory(
                self, self.tr("Select Material Library Directory"), self.matlib_path
            )
        )

        if load_path != "":
            try:
                self.matlib.load_mat_ref(load_path)
                self.update_list_mat()
                self.nav_mat.setCurrentRow(0)
                self.update_out()
                self.matlib_path = dirname(load_path)
            except Exception as e:
                QMessageBox().critical(
                    self,
                    self.tr("Error"),
                    self.tr(
                        "The material library file is " "incorrect:\n",
                        "Please keep the \n, another " "message is following this one",
                    )
                    + type(e).__name__
                    + ": "
                    + str(e),
                )
                self.reject()
        else:
            self.reject() 
開發者ID:Eomys,項目名稱:pyleecan,代碼行數:43,代碼來源:DMatLib.py

示例11: searchOneFolderMusic

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getExistingDirectory [as 別名]
def searchOneFolderMusic(self):
        url = QFileDialog.getExistingDirectory()
        if url:
            self.scanFolder(url) 
開發者ID:dragondjf,項目名稱:QMusic,代碼行數:6,代碼來源:muscimanageworker.py

示例12: macroSelectDir

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getExistingDirectory [as 別名]
def macroSelectDir(self):

        try:

            fileName = str(QFileDialog.getExistingDirectory(self, "Select Directory"))
            self.dir = fileName.replace("/","\\")
            self.makrosavedir.setText(self.dir)

        except:
            pass 
開發者ID:azizaltuntas,項目名稱:Camelishing,代碼行數:12,代碼來源:start.py

示例13: import_folder_clicked

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getExistingDirectory [as 別名]
def import_folder_clicked(self):
        path = QFileDialog.getExistingDirectory(
            self, _("TEXT_FILE_IMPORT_FOLDER"), self.default_import_path
        )
        if not path:
            return
        p = pathlib.Path(path)
        files, total_size = self.get_folder(p)
        self.default_import_path = str(p)
        self.import_all(files, total_size) 
開發者ID:Scille,項目名稱:parsec-cloud,代碼行數:12,代碼來源:files_widget.py

示例14: export_labels_annots

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getExistingDirectory [as 別名]
def export_labels_annots(self,dataset_vo: DatasetVO, export_format):

        selected_folder = str(QFileDialog.getExistingDirectory(None, "select the folder"))
        if selected_folder:
            @work_exception
            def do_work():
                annotations = self._annot_dao.fetch_labels(dataset_vo.id)
                return annotations, None

            @gui_exception
            def done_work(result):
                annots, err = result
                if err:
                    raise err
                if annots:
                    output_file = Path(selected_folder)\
                        .joinpath("annotations.{}".format(export_format))
                    if export_format == "csv":
                        df = pd.DataFrame(annots)
                        df.to_csv(str(output_file),
                                  index=False)
                    else:
                        def dumper(obj):
                            try:
                                return obj.toJSON()
                            except:
                                return obj.__dict__
                        with open(output_file, "w") as f:
                            f.write(json.dumps(annots, default=dumper, indent=2))

                    GUIUtilities.show_info_message("Annotations exported successfully", "Done")
                else:
                    GUIUtilities.show_info_message("Not annotations found for the dataset {}".format(dataset_vo.name),"Done")

            worker = Worker(do_work)
            worker.signals.result.connect(done_work)
            self.thread_pool.start(worker) 
開發者ID:haruiz,項目名稱:CvStudio,代碼行數:39,代碼來源:tab_datasets.py

示例15: export_boxes_annots

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getExistingDirectory [as 別名]
def export_boxes_annots(self, dataset_vo: DatasetVO, export_format):

        selected_folder = str(QFileDialog.getExistingDirectory(None, "select the folder"))
        if selected_folder:
            @work_exception
            def do_work():
                annotations = self._annot_dao.fetch_boxes(dataset_vo.id)
                return annotations, None

            @gui_exception
            def done_work(result):
                annots, err = result
                if err:
                    raise err
                if annots:
                    output_file = Path(selected_folder) \
                        .joinpath("annotations.{}".format(export_format))
                    if export_format == "csv":
                        df = pd.DataFrame(annots)
                        df.to_csv(str(output_file),
                                  index=False)
                    else:
                        def dumper(obj):
                            try:
                                return obj.toJSON()
                            except:
                                return obj.__dict__

                        with open(output_file, "w") as f:
                            f.write(json.dumps(annots, default=dumper, indent=2))
                    GUIUtilities.show_info_message("Annotations exported successfully", "Done")
                else:
                    GUIUtilities.show_info_message("Not annotations found for the dataset {}".format(dataset_vo.name), "Done")

            worker = Worker(do_work)
            worker.signals.result.connect(done_work)
            self.thread_pool.start(worker) 
開發者ID:haruiz,項目名稱:CvStudio,代碼行數:39,代碼來源:tab_datasets.py


注:本文中的PyQt5.QtWidgets.QFileDialog.getExistingDirectory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。