python类QFileDialog()的实例源码

fit_model_tab.py 文件源码 项目:MDT 作者: cbclab 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _select_std_file(self):
        open_file, used_filter = QFileDialog().getOpenFileName(
            caption='Select a noise std volume', directory=self._shared_state.base_dir,
            filter=';;'.join(image_files_filters))

        if open_file:
            self._shared_state.base_dir = os.path.dirname(open_file)
            self.noiseStd.setText(open_file)
fit_model_tab.py 文件源码 项目:MDT 作者: cbclab 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def _select_grad_dev_file(self):
        open_file, used_filter = QFileDialog().getOpenFileName(
            caption='Select a gradient deviations volume', directory=self._shared_state.base_dir,
            filter=';;'.join(image_files_filters))

        if open_file:
            self._shared_state.base_dir = os.path.dirname(open_file)
            self.gradientDeviations.setText(open_file)
fit_model_tab.py 文件源码 项目:MDT 作者: cbclab 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _select_value_file(self):
        open_file, used_filter = QFileDialog().getOpenFileName(
            caption='Select a noise std volume', directory=self._shared_state.base_dir,
            filter=';;'.join(image_files_filters))

        if open_file:
            self._shared_state.base_dir = os.path.dirname(open_file)
            self.valueInput.setText(open_file)
qt_main.py 文件源码 项目:MDT 作者: cbclab 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _select_output_folder(self):
        initial_dir = self._shared_state.base_dir
        if self.outputFile.text() != '':
            initial_dir = self.outputFile.text()

        output_dir = QFileDialog().getExistingDirectory(
            caption='Select the output folder', directory=initial_dir)

        if output_dir:
            self.outputFile.setText(output_dir)
            self._shared_state.base_dir = output_dir
test_{{cookiecutter.application_name}}.py 文件源码 项目:cookiecutter-pyqt5 作者: mandeep 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_open_file(window, qtbot, mock):
    """Test the Open File item of the File submenu.

    Qtbot clicks on the file sub menu and then navigates to the Open File item. Mock creates
    an object to be passed to the QFileDialog.
    """
    qtbot.mouseClick(window.file_sub_menu, Qt.LeftButton)
    qtbot.keyClick(window.file_sub_menu, Qt.Key_Down)
    mock.patch.object(QFileDialog, 'getOpenFileName', return_value=('', ''))
    qtbot.keyClick(window.file_sub_menu, Qt.Key_Enter)
main_window.py 文件源码 项目:Enibar 作者: ENIB 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def export(self, notes):
        """ Generic export notes function """
        path, _ = QtWidgets.QFileDialog(self).getSaveFileName(
            self,
            "Exporter vers",
            "{}.csv".format(datetime.datetime.now().strftime("%Y-%m-%d")),
            "CSV Files (*.csv)"
        )

        if path:
            try:
                with open(path, "w") as save_file:
                    save_file.write(api.notes.export(notes))
            except PermissionError:
                gui.utils.error("Erreur", "Impossible d'écrire ici")
notes_management_window.py 文件源码 项目:Enibar 作者: ENIB 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def add_photo(self):
        """ Function called to add a photo. Open a QFileDialog and fill
            self.photo with the selected image
        """
        self.photo_selected = QtWidgets.QFileDialog(self).getOpenFileUrl(
            self, "Selectionnez une image", settings.IMG_BASE_DIR,
            "Image Files (*.png *.jpg *.bmp)")[0].path()

        if self.photo_selected:
            image = QtGui.QPixmap(self.photo_selected)

            if not image.isNull():
                self.photo.setPixmap(image.scaled(QtCore.QSize(120, 160)))
                self.on_change()
group_actions_window.py 文件源码 项目:Enibar 作者: ENIB 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def export_csv_action(self):
        """ Called when "Export CSV" is clicked
        """
        path, _ = QtWidgets.QFileDialog(self).getSaveFileName(
            self, "Exporter vers", "{}.csv".format(
                datetime.datetime.now().strftime("%Y-%m-%d")),
            "CSV Files (*.csv)")
        if path:
            try:
                with open(path, "w") as save_file:
                    save_file.write(self._multiple_action(api.notes.export_by_nick, with_coeffs=False))
            except PermissionError:
                error("Erreur", "Impossible d'écrire ici")
gui.py 文件源码 项目:ripr 作者: pbiernat 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def _saveCode(self):
            codeobj = self._get_selected_codeobj()
            dialog = QtWidgets.QFileDialog(None, None)
            dialog.setFileMode(QtWidgets.QFileDialog.AnyFile)
            if dialog.exec_():
                fileNames = dialog.selectedFiles()
                if len(fileNames) > 0:
                    f = open(fileNames[0], 'wb')
                    f.write(codeobj.final)
                    f.close()
HandWriteRecognition.py 文件源码 项目:pyqt5 作者: yurisnm 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def init_ui(self):
        self._fileDialog = QFileDialog(self)
        self._v_layout = QVBoxLayout()
        self._v_layout.setSpacing(2)
        self.setLayout(self._v_layout)
        self._path = "TEXT.png"
        self._pixmap = QPixmap(self._path)
        self._btnFile = QPushButton("Open")
        self._hWidget = QWidget()
        self._hLayout = QHBoxLayout()
        self._hWidget.setLayout(self._hLayout)

        self._image = Image.open(self._path)
        self._line = QLineEdit()

        self._hLayout.addWidget(self._btnFile)
        self._hLayout.addWidget(self._line)
        size = QSize(160, 90)
        pix = self._pixmap.scaled(size, transformMode=Qt.SmoothTransformation)

        self._lbl = QLabel()
        self._lbl.setPixmap(pix)
        self._v_layout.addWidget(self._lbl)
        self._v_layout.addWidget(self._hWidget)
        self._btnFile.clicked.connect(self.openFilePressed)

        self._line.setText(pytesseract.image_to_string(Image.open('TEXT.png')))
worksetdialog.py 文件源码 项目:Worksets 作者: DozyDolphin 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def select_file(self):
        if self.init_line_edit.text() == "":
            script_dir = self.controller.get_script_dir()
        else:
            script_dir = self.init_line_edit.text()

        file_dialog = QtWidgets.QFileDialog()
        file_dialog.setDirectory(script_dir)
        file_tuple = file_dialog.getOpenFileName()
        if not file_tuple[0] == '':
            self.init_line_edit.setText(file_tuple[0])
settingsdialog.py 文件源码 项目:Worksets 作者: DozyDolphin 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _choose_dir(self):
        sender = self.sender()
        if sender.objectName() == 'script_dir_picker':
            receiver = self.script_dir_input
        elif sender.objectName() == 'log_dir_picker':
            receiver = self.log_dir_input
        directory = receiver.text()

        dialog = QtWidgets.QFileDialog()
        folder_path = dialog.getExistingDirectory(self, _("Select Folder"), directory)
        if not folder_path == '':
            receiver.setText(folder_path)
ui_main.py 文件源码 项目:python-get-girl-image 作者: JadenTseng 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def slot_openFileManager(self):
        open = QFileDialog()
        self.path = open.getExistingDirectory()
        self.save_path_lineEdit.setText(self.path)
        print(self.path)
pyqt-sqlite.py 文件源码 项目:pyqt-sqlite 作者: mbaser 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def on_actionNew_triggered(self):
        save_file_dialog=QtWidgets.QFileDialog.getSaveFileName(self, "Name of new database", self.work_directory)
        if save_file_dialog[0]:
            self.loadDatabase(save_file_dialog[0])
pyqt-sqlite.py 文件源码 项目:pyqt-sqlite 作者: mbaser 项目源码 文件源码 阅读 41 收藏 0 点赞 0 评论 0
def on_actionOpen_triggered(self):
        self.fileDialog = QtWidgets.QFileDialog(self)
        self.fileDialog.setDirectory(self.work_directory)

        result=self.fileDialog.getOpenFileName()

        if result[0]:
            self.loadDatabase(result[0])
Visualizer.py 文件源码 项目:Visualization 作者: nwrush 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _open_visualization(self):
        dialog = QtWidgets.QFileDialog(self)
        dialog.setFileMode(QtWidgets.QFileDialog.ExistingFiles)
        dialog.setNameFilters(["Processed data file (*.p)", "All Files (*)"])
        dialog.exec()

        fnames = dialog.selectedFiles()
        if fnames:
            for fname in fnames:
                self._processed_file(fname)
wizards.py 文件源码 项目:fomod-designer 作者: GandaG 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _create_field(self, element):
        """
        :param element: the element newly copied
        :return: base QWidget, with the source and destination fields built
        """
        def button_clicked():
            open_dialog = QFileDialog()
            if element.tag == "file":
                file_path = open_dialog.getOpenFileName(self, "Select File:", self.kwargs["package_path"])
                if file_path[0]:
                    item_ui.edit_source.setText(relpath(file_path[0], self.kwargs["package_path"]))
            elif element.tag == "folder":
                folder_path = open_dialog.getExistingDirectory(self, "Select folder:", self.kwargs["package_path"])
                if folder_path:
                    item_ui.edit_source.setText(relpath(folder_path, self.kwargs["package_path"]))

        parent_element = element.getparent()

        item = QWidget()
        item_ui = wizard_files_item.Ui_base()
        item_ui.setupUi(item)

        # set initial values
        item_ui.edit_source.setText(element.properties["source"].value)
        item_ui.edit_dest.setText(element.properties["destination"].value)
        item_ui.button_delete.setIcon(QIcon(join(cur_folder, "resources/logos/logo_cross.png")))

        # connect the signals
        item_ui.edit_source.textChanged.connect(element.properties["source"].set_value)
        item_ui.edit_source.textChanged.connect(element.write_attribs)
        item_ui.edit_source.textChanged.connect(lambda: self.code_changed.emit(parent_element))
        item_ui.edit_dest.textChanged.connect(element.properties["destination"].set_value)
        item_ui.edit_dest.textChanged.connect(element.write_attribs)
        item_ui.edit_dest.textChanged.connect(lambda: self.code_changed.emit(parent_element))
        item_ui.button_source.clicked.connect(button_clicked)
        item_ui.button_delete.clicked.connect(item.deleteLater)
        item_ui.button_delete.clicked.connect(lambda _: parent_element.remove_child(element))
        item_ui.button_delete.clicked.connect(lambda: self.code_changed.emit(parent_element))

        return item


问题


面经


文章

微信
公众号

扫码关注公众号