Python PyQt5.QtWidgets.QFileDialog.getExistingDirectory() Examples

The following are 30 code examples of PyQt5.QtWidgets.QFileDialog.getExistingDirectory(). 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: addlink.py    From persepolis with GNU General Public License v3.0 8 votes vote down vote up
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. 
Example #2
Source File: driveit-gui.py    From DriveIt with Do What The F*ck You Want To Public License 6 votes vote down vote up
def show_file_dialog(self):
        selected_dir = QFileDialog.getExistingDirectory(self, caption='Choose Directory', directory=os.getcwd())
        self.lineEdit_save_location.setText(selected_dir) 
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_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
################################################################ 
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_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) 
Example #5
Source File: engine.py    From autokey with GNU General Public License v3.0 5 votes vote down vote up
def on_browse_button_pressed(self):
        """
        PyQt slot called when the user hits the "Browse" button.
        Display a directory selection dialog and store the returned path.
        """
        path = QFileDialog.getExistingDirectory(self.parentWidget(), "Choose a directory containing Python modules")

        if path:  # Non-empty means the user chose a path and clicked on OK
            self.path = path
            self.clear_button.setEnabled(True)
            self.folder_label.setText(path)
            logger.debug("User selects a custom module search path: {}".format(self.path)) 
Example #6
Source File: properties.py    From persepolis with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #7
Source File: gui.py    From PUBGIS with GNU General Public License v3.0 5 votes vote down vote up
def _select_output_directory(self):
        dir_name = QFileDialog.getExistingDirectory(directory=self.last_output_live_dir,
                                                    options=QFileDialog.ShowDirsOnly)
        self._set_output_directory(dir_name) 
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_5_clicked(self):
        """
        设置工作目录
        """
        work_path = QFileDialog.getExistingDirectory(self,'设置工作目录','./')
        if work_path:
            self.my_bwm_parameter['work_path']=work_path+'/'
            if len(work_path)>20:
                smaller_work_path = work_path[:10]+work_path[-10:]
            else:
                smaller_work_path = work_path
            self.label_10.setText(smaller_work_path) 
Example #9
Source File: settingsdialog.py    From lector with GNU General Public License v2.0 5 votes vote down vote up
def on_dictDirButton_clicked(self):
        dictDir = QFileDialog.getExistingDirectory(self,
                  self.tr("Choose your dictionary directory..."),
                  self.ui.directoryLine.text(),
                  QFileDialog.DontResolveSymlinks | QFileDialog.ShowDirsOnly)

        if not dictDir.isEmpty():
            self.ui.directoryLine.setText(dictDir)
            self.langList(dictDir) 
Example #10
Source File: settingsdialog.py    From lector with GNU General Public License v2.0 5 votes vote down vote up
def on_pbTessData_clicked(self):
        dictDir = QFileDialog.getExistingDirectory(self,
                  self.tr("Select Path Prefix To tessdata Directory..."),
                  self.ui.lnTessData.text(),
                  QFileDialog.DontResolveSymlinks | QFileDialog.ShowDirsOnly)

        if not dictDir.isEmpty():
            self.ui.lnTessData.setText(dictDir) 
Example #11
Source File: FileOperator.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def get_directory():
    directory = QFileDialog.getExistingDirectory(None, "Choose Directory", QDir.homePath(),
                                                 QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks)
    return directory 
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_saveoutput_cross_released(self):
        lati = int(self.ui.midpt_latitude.value())
        longi = int(self.ui.midpt_longitude.value())
        azi_cross = int(self.ui.azimuth.value())
        selected_directory2 = QFileDialog.getExistingDirectory()

        if not selected_directory2:
            return

        if os.path.isdir(str(selected_directory2) + '/output_crosssection_' +\
         str(lati) + '_' + str(longi) + '_' + str(azi_cross)):

            QMessageBox.critical(None, "Message", "This directory already exists in this directory")
        else:
            os.mkdir(str(selected_directory2) + '/output_crosssection_' + str(lati) + '_' + str(longi) + '_' + str(azi_cross))
            files_to_copy1 = set(glob.glob(DIR2 + 'output_files_cross/output_cross_*'))
            for _files in files_to_copy1:
                shutil.copyfile( _files, \
                    str(selected_directory2) + '/output_crosssection_' + str(lati) + '_' + str(longi) + '_' + str(azi_cross)+ '/' + os.path.splitext(os.path.basename(_files))[0]+'.out')
            files_to_copy2 = set(glob.glob(DIR2 + 'output_files_cross/*.sph'))
            for _files in files_to_copy2:
                shutil.copyfile( _files, \
                    str(selected_directory2) + '/output_crosssection_' + str(lati) + '_' + str(longi) + '_' + str(azi_cross) + '/' + os.path.splitext(os.path.basename(_files))[0] +'.sph')
                
            path = DIR2 + "/output_files_cross"
            dirs = os.listdir(path)
            os.chdir(DIR2 + '/output_files_cross')
            for i in range(len(dirs)):
                os.remove(dirs[i])
            os.chdir(DIR)

################################################################
#                      TOOLS FOR MAP
################################################################ 
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_savefig_path_released(self):

        selected_directory6 = QFileDialog.getExistingDirectory()

        if not selected_directory6:
            return

        if os.path.isfile(str(selected_directory6) + '/path.pdf'):
            QMessageBox.critical(None, "Message", "This figure already exists in this directory")
        else:
            self.fig_path.savefig(str(selected_directory6) + '/path.pdf',bbox_inches='tight') 
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_savefig_spec_released(self):

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

        selected_directory6 = QFileDialog.getExistingDirectory()

        if not selected_directory6:
            return

        if os.path.isfile(str(selected_directory6) + '/spectre_' + str(dep_spec) \
            + 'km.pdf'):
            QMessageBox.critical(None, "Message", "This figure already exists in this directory")
        else:
            self.fig_spec.savefig(str(selected_directory6) + '/spectre_' + str(dep_spec) \
            + 'km.pdf',bbox_inches='tight') 
Example #15
Source File: seistomopy_gui.py    From SeisTomoPy_V3 with GNU General Public License v3.0 5 votes vote down vote up
def on_savefig_corr_released(self):

        dep_corr1 = int(self.ui.depth1_corr.value())
        dep_corr2 = int(self.ui.depth2_corr.value())

        selected_directory6 = QFileDialog.getExistingDirectory()

        if not selected_directory6:
            return

        if os.path.isfile(str(selected_directory6) + '/correlation.pdf'):
        	QMessageBox.critical(None, "Message", "This figure already exists in this directory")
        else:
        	self.fig_corr.savefig(str(selected_directory6) + '/correlation.pdf',bbox_inches='tight') 
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: downloader.py    From YouTubeDownload with MIT License 5 votes vote down vote up
def browse_folder(self):
        self.output_path.setText(os.path.abspath(str(QFileDialog.getExistingDirectory(self,
                                                                                      'Select Output Directory')))) 
Example #18
Source File: comic_gui.py    From ComicSpider with GNU General Public License v3.0 5 votes vote down vote up
def select_dir(self):
        '''
        弹出文件对话框选择保存目录
        '''
        self.dir=QFileDialog.getExistingDirectory(self,'选择保存路径',(self.dirname if self.dirname else './')) 
Example #19
Source File: setting.py    From persepolis with GNU General Public License v3.0 5 votes vote down vote up
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)) 
Example #20
Source File: WGuiOption.py    From pyleecan with Apache License 2.0 5 votes vote down vote up
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") 
Example #21
Source File: DMatLib.py    From pyleecan with Apache License 2.0 5 votes vote down vote up
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() 
Example #22
Source File: muscimanageworker.py    From QMusic with GNU Lesser General Public License v2.1 5 votes vote down vote up
def searchOneFolderMusic(self):
        url = QFileDialog.getExistingDirectory()
        if url:
            self.scanFolder(url) 
Example #23
Source File: start.py    From Camelishing with MIT License 5 votes vote down vote up
def macroSelectDir(self):

        try:

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

        except:
            pass 
Example #24
Source File: files_widget.py    From parsec-cloud with GNU Affero General Public License v3.0 5 votes vote down vote up
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) 
Example #25
Source File: setting.py    From persepolis with GNU General Public License v3.0 5 votes vote down vote up
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)) 
Example #26
Source File: BatchProcessing.py    From tierpsy-tracker with MIT License 5 votes vote down vote up
def getMasksDir(self):
        mask_files_dir = QFileDialog.getExistingDirectory(
            self,
            "Selects the directory where the hdf5 masked videos will be stored",
            self.mask_files_dir)
        if mask_files_dir:
            self.updateMasksDir(mask_files_dir) 
Example #27
Source File: tab_datasets.py    From CvStudio with MIT License 5 votes vote down vote up
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) 
Example #28
Source File: tab_datasets.py    From CvStudio with MIT License 5 votes vote down vote up
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) 
Example #29
Source File: tab_datasets.py    From CvStudio with MIT License 5 votes vote down vote up
def export_polygons_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_polygons(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) 
Example #30
Source File: tab_datasets.py    From CvStudio with MIT License 5 votes vote down vote up
def export_all_annot(self,dataset_vo: DatasetVO ):
        selected_folder = str(QFileDialog.getExistingDirectory(None, "select the folder"))
        if selected_folder:
            @work_exception
            def do_work():
                annotations = self._annot_dao.fetch_all_by_dataset(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.json")
                    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)