本文整理汇总了Python中qtpy.QtWidgets.QFileDialog类的典型用法代码示例。如果您正苦于以下问题:Python QFileDialog类的具体用法?Python QFileDialog怎么用?Python QFileDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QFileDialog类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: saveText
def saveText(self):
"""
Saves the generated text to a file (opens file dialog).
"""
fname = QFileDialog.getSaveFileName(self, 'Open file', '')
if isinstance(fname, tuple):
fname = fname[0]
fid = open(fname, 'w')
fid.write(self.genText())
fid.close()
开发者ID:mantidproject,项目名称:mantid,代码行数:10,代码来源:PyChopGui.py
示例17: show_savecfg_dlg
def show_savecfg_dlg(self):
filename, _ = QFileDialog.getSaveFileName(
self, self.tr("Save configuration file..."),
directory=os.path.expanduser("~"),
filter="Json file (*.json)"
)
if filename:
self.filename = filename
self.save_file()
开发者ID:MrLeeh,项目名称:jsonwatchqt,代码行数:10,代码来源:mainwindow.py
示例18: _output_dir_browse
def _output_dir_browse(self):
output_dir = QFileDialog.getExistingDirectory(self, "Output Directory - Choose a directory",
os.path.expanduser('~'),
QFileDialog.ShowDirsOnly
| QFileDialog.DontResolveSymlinks)
if not output_dir:
return
if isinstance(output_dir, tuple):
output_dir = output_dir[0]
self._summary.output_dir_edit.setText(output_dir)
self._settings.emit_key_value("OUTPUT_DIR", output_dir)
开发者ID:mantidproject,项目名称:mantid,代码行数:11,代码来源:eqsans_instrument.py
示例19: target_autonom_clicked
def target_autonom_clicked(self):
_autonom_folder = QFileDialog.getExistingDirectory(caption="Select Output autoNOM Folder ...",
directory=self.parent.current_folder,
options=QFileDialog.ShowDirsOnly)
if not _autonom_folder:
return
if isinstance(_autonom_folder, tuple):
_autonom_folder = _autonom_folder[0]
_autonom_folder = os.path.basename(_autonom_folder)
self.ui.target_autonom_value.setText(str(_autonom_folder))
self.check_status_transfer_button()
开发者ID:neutrons,项目名称:FastGR,代码行数:11,代码来源:ipts_file_transfer_dialog.py
示例20: browse_File
def browse_File(self):
""" Open a file dialog to get file
"""
filename = QFileDialog.getOpenFileName(self, 'Input File Dialog',
self._defaultdir, "Data (*.nxs *.dat);;All files (*)")
if isinstance(filename, tuple):
filename = filename[0]
self.ui.lineEdit.setText(filename)
Logger("Filter_Events").information('Selected file: "{}"'.format(filename))
开发者ID:mantidproject,项目名称:mantid,代码行数:11,代码来源:eventFilterGUI.py
注:本文中的qtpy.QtWidgets.QFileDialog类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论