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


Python QtWidgets.QFileDialog類代碼示例

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


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

示例1: __init__

    def __init__(self, parent):
        QFileDialog.__init__(self, parent)
        self.setFileMode(QFileDialog.AnyFile)
        self.setAcceptMode(QFileDialog.AcceptSave)

        # Widgets
        self._chk_tight = QCheckBox('Tight layout')

        self._txt_dpi = QSpinBox()
        self._txt_dpi.setRange(1, 10000)
        self._txt_dpi.setSingleStep(50)
        self._txt_dpi.setSuffix('dpi')
        self._txt_dpi.setValue(100)

        # Layouts
        layout = self.layout()

        lyt_extras = QHBoxLayout()
        lyt_extras.addWidget(QLabel('Extra options'))
        lyt_extras.addWidget(self._chk_tight)
        lyt_extras.addWidget(QLabel('Resolution'))
        lyt_extras.addWidget(self._txt_dpi)
        layout.addLayout(lyt_extras, layout.rowCount(), 0, 1, layout.columnCount())

        self.setLayout(layout)
開發者ID:pyhmsa,項目名稱:pyhmsa-gui,代碼行數:25,代碼來源:toolbar.py

示例2: select_manual_output_folder

 def select_manual_output_folder(self):
     # _current_folder = self.main_window.current_folder
     dlg = QFileDialog(parent=self.main_window,
                       caption="Select or Define Output Directory")
     dlg.setFileMode(QFileDialog.Directory)
     if dlg.exec_():
         output_folder_name = str(dlg.selectedFiles()[0])
         self.main_window.autonom_ui.manual_output_folder_field.setText(output_folder_name)
開發者ID:neutrons,項目名稱:FastGR,代碼行數:8,代碼來源:step1_gui_handler.py

示例3: _export

    def _export(self):
        """
            Exports the current content of the UI to a python script that can
            be run within MantidPlot
        """
        if self._interface is None:
            return

        fname = QFileDialog.getSaveFileName(self, "Mantid Python script - Save script",
                                            self._last_export_directory,
                                            "Python script (*.py)")
        if not fname:
            return

        if isinstance(fname, tuple):
            fname = fname[0]
        fname = str(fname)
        if not fname.endswith('.py'):
            fname += ".py"
        (folder, file_name) = os.path.split(fname)
        self._last_export_directory = folder
        script = self._interface.export(fname)
        if script is not None:
            self.statusBar().showMessage("Saved as %s" % fname)
        else:
            self.statusBar().showMessage("Could not save file")
開發者ID:samueljackson92,項目名稱:mantid,代碼行數:26,代碼來源:reduction_application.py

示例4: do_export_selected_scans

    def do_export_selected_scans(self):
        """
        export selected scans to a file
        :return:
        """
        # get the scans
        scans_list = self._myParent.ub_matrix_processing_table.get_selected_scans()
        scans_list.sort()

        # form the output string
        output_str = '# Exp = {0}.\n'.format(self._myParent.current_exp_number)
        for scan in scans_list:
            output_str += '{0}, '.format(scan)

        # trim the last
        output_str = output_str[:-2]

        # get the output file name
        file_filter = 'Text Files (*.dat);;All Files (*.*)'
        file_name = QFileDialog.getSaveFileName(self, 'File to export selected scans',
                                                self._myParent.working_directory, file_filter)
        if not file_name:
            return
        if isinstance(file_name, tuple):
            file_name = file_name[0]

        # write file
        out_file = open(file_name, 'w')
        out_file.write(output_str)
        out_file.close()
開發者ID:mantidproject,項目名稱:mantid,代碼行數:30,代碼來源:FindUBUtility.py

示例5: output_dir_button_clicked

 def output_dir_button_clicked(self):
     _output_folder = QFileDialog.getExistingDirectory(caption="Select Output Folder ...",
                                                       directory=self.parent.output_folder,
                                                       options=QFileDialog.ShowDirsOnly)
     if _output_folder:
         self.ui.output_dir_label.setText(str(_output_folder))
         self.parent.output_folder = str(_output_folder)
開發者ID:neutrons,項目名稱:FastGR,代碼行數:7,代碼來源:advanced_file_window.py

示例6: cache_dir_button_clicked

 def cache_dir_button_clicked(self):
     _cache_folder = QFileDialog.getExistingDirectory(caption="Select Cache Folder ...",
                                                      directory=self.parent.cache_folder,
                                                      options=QFileDialog.ShowDirsOnly)
     if _cache_folder:
         self.ui.cache_dir_label.setText(str(_cache_folder))
         self.parent.cache_folder = str(_cache_folder)
開發者ID:neutrons,項目名稱:FastGR,代碼行數:7,代碼來源:advanced_file_window.py

示例7: request_config_file_name

    def request_config_file_name(self, open_flag=True):
        _caption = 'Select or Define a Configuration File Name'
        _current_folder = self.parent.configuration_folder
        if open_flag:
            _file = QFileDialog.getOpenFileName(parent=self.parent,
                                                filter='config (*.cfg)',
                                                caption=_caption,
                                                directory=_current_folder)
            if isinstance(_file, tuple):
                _file = _file[0]
        else:
            _file, _ = get_save_file(parent=self.parent,
                                     filter={'config (*.cfg)':'cfg'},
                                     caption=_caption,
                                     directory=_current_folder)

        if not _file:
            self.filename = ''
            return

        _new_path = os.path.dirname(_file)
        self.parent.configuration_folder = _new_path
        o_file_handler = FileHandler(filename=_file)
        o_file_handler.check_file_extension(ext_requested='cfg')
        self.filename = o_file_handler.filename
開發者ID:neutrons,項目名稱:FastGR,代碼行數:25,代碼來源:config_file_name_handler.py

示例8: browse_file

    def browse_file(self, type='calibration'):

        if type == 'calibration':
            _current_folder = self.parent.calibration_folder
            _filter = "calib (*.h5);;all (*.*)"
            _caption = "Select Calibration File"
            _output_ui = self.parent.ui.mantid_calibration_value
        else:
            _current_folder = self.parent.characterization_folder
            _filter = "characterization (*-rietveld.txt);;all (*.*)"
            _caption = "Select Characterization File"
            _output_ui = self.parent.ui.mantid_characterization_value

        _file = QFileDialog.getOpenFileName(parent=self.parent,
                                            filter=_filter,
                                            caption=_caption,
                                            directory=_current_folder)
        if not _file:
            return
        if isinstance(_file, tuple):
            _file = _file[0]

        _output_ui.setText(str(_file))
        _path = os.path.dirname(str(_file))

        if type == 'calibration':
            self.parent.calibration_current_folder = _path
        else:
            self.parent.characterization_current_folder = _path
開發者ID:neutrons,項目名稱:FastGR,代碼行數:29,代碼來源:browse_file_folder_handler.py

示例9: open_file

 def open_file(self):
     # todo: when more file types are added this should
     # live in its own type
     filepath, _ = QFileDialog.getOpenFileName(self, "Open File...", "", "Python (*.py)")
     if not filepath:
         return
     self.editor.open_file_in_new_tab(filepath)
開發者ID:DanNixon,項目名稱:mantid,代碼行數:7,代碼來源:mainwindow.py

示例10: _save_as

    def _save_as(self):
        """
            Present a file dialog to the user and saves the content of
            the UI in XML format.
        """
        if self._filename is not None:
            fname = self._filename
        else:
            fname = self._instrument + '_'

        fname = QFileDialog.getSaveFileName(self, "Reduction settings - Save settings",
                                            self._last_directory + '/' + fname,
                                            "Settings files (*.xml)")
        if not fname:
            return

        if isinstance(fname, tuple):
            fname = fname[0]
        fname = str(QFileInfo(fname).filePath())
        if not fname.endswith('.xml'):
            fname += ".xml"
        if fname in self._recent_files:
            self._recent_files.remove(fname)
        self._recent_files.insert(0,fname)
        while len(self._recent_files) > 10:
            self._recent_files.pop()
        self._last_directory = QFileInfo(fname).path()
        self._filename = fname
        self._save()
開發者ID:samueljackson92,項目名稱:mantid,代碼行數:29,代碼來源:reduction_application.py

示例11: open_file_dialog

def open_file_dialog(line_edit, filter_text, directory):
    file_name = QFileDialog.getOpenFileName(None, 'Open', directory, filter_text)
    if not file_name:
        return
    if isinstance(file_name, tuple):
        file_name = file_name[0]
    line_edit.setText(file_name)
開發者ID:samueljackson92,項目名稱:mantid,代碼行數:7,代碼來源:gui_common.py

示例12: _on_load_from_file

    def _on_load_from_file(self):
        filename = QFileDialog.getOpenFileName(
            self, caption='Load Model',
            filter=SPECVIZ_MODEL_FILE_FILTER)[0]
        if not filename:
            return

        self._load_model_from_file(filename)
開發者ID:nmearl,項目名稱:specviz,代碼行數:8,代碼來源:model_editor.py

示例13: grouping_button

 def grouping_button(self, key=None, grouping_type='input'):
     message = "Select {} grouping".format(grouping_type)
     ext = 'Grouping (*.txt);;All (*.*)'
     file_name = QFileDialog.getOpenFileName(self.main_window,
                                             message,
                                             self.main_window.calibration_folder,
                                             ext)
     if file_name is None:
         return
開發者ID:neutrons,項目名稱:FastGR,代碼行數:9,代碼來源:table_row_handler.py

示例14: _savedir_browse

 def _savedir_browse(self):
     save_dir = QFileDialog.getExistingDirectory(self, "Output Directory - Choose a directory",
                                                       os.path.expanduser('~'),
                                                       QFileDialog.ShowDirsOnly
                                                       | QFileDialog.DontResolveSymlinks)
     if not save_dir:
         return
     if isinstance(save_dir, tuple):
         save_dir = save_dir[0]
     self._content.savedir_edit.setText(save_dir)
開發者ID:samueljackson92,項目名稱:mantid,代碼行數:10,代碼來源:dgs_sample_setup.py

示例15: get_directory_name_for_saving

 def get_directory_name_for_saving(self):
     """
     Pops up a directory selection dialogue
     :return : The path to the directory
     """
     # Note that the native dialog does not always show the files
     # in the directory on Linux, but using the non-native dialog
     # is not very pleasant on Windows or Mac
     directory = QFileDialog.getExistingDirectory(caption='Select folder for exported plots')
     return directory
開發者ID:mantidproject,項目名稱:mantid,代碼行數:10,代碼來源:view.py


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