Ejemplo n.º 1
0
 def _put_existing_dir_path_in_lineedit(self, lineedit):
     path = QDir.toNativeSeparators(
         QFileDialog.getExistingDirectoryUrl(self.window).path())
     if (os.name == "nt"):
         # Remove the root slash
         path = path[1:]
     lineedit.setText(path)
Ejemplo n.º 2
0
    def select_folder(self):
        dialog = QFileDialog()
        dialog.setFileMode(QFileDialog.Directory)
        dialog.setOption(QFileDialog.ShowDirsOnly)

        self.directoryUrl = dialog.getExistingDirectoryUrl()

        self.selected_folder = self.directoryUrl.toDisplayString()[7:]
        self.nameFileArray = [
            f for f in os.listdir(self.selected_folder)
            if os.path.isfile(os.path.join(self.selected_folder, f))
        ]

        # item = QStandardItem("All")
        # item.setCheckState(Qt.Checked)
        # item.setCheckable(True)
        #self.file_model.appendRow(item)

        #self.file_model, self.file_option_listview = self.create_checkBoxes(self.nameFileArray, self.file_model, self.file_option_listview)

        self.file_model = self.create_checkBoxes(self.nameFileArray,
                                                 self.file_model,
                                                 self.file_list_view)
        for name in self.nameFileArray:
            self.file_model.appendRow(
                self.append_checkbox(name, self.file_model, Qt.Checked))
        self.file_list_view.setModel(self.file_model)
Ejemplo n.º 3
0
def openDir(parent, caption_str: str, current_dir_str: Union[Any, str]):
    options = QFileDialog.Options()
    options |= QFileDialog.ShowDirsOnly

    file_dialog: QUrl = QFileDialog.getExistingDirectoryUrl(
        parent, caption=caption_str, dir=current_dir_str, options=options)
    if file_dialog:
        return file_dialog.toLocalFile()
    return None
Ejemplo n.º 4
0
def file_chooser_open_directory(parent) -> QUrl:
    dialog = QFileDialog(parent)
    dialog.setFileMode(QFileDialog.Directory)
    dialog.setOption(QFileDialog.ShowDirsOnly, True)
    url = dialog.getExistingDirectoryUrl()
    return url