本文整理汇总了Python中qtpy.QtWidgets.QFileDialog.getOpenFileNames方法的典型用法代码示例。如果您正苦于以下问题:Python QFileDialog.getOpenFileNames方法的具体用法?Python QFileDialog.getOpenFileNames怎么用?Python QFileDialog.getOpenFileNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QFileDialog
的用法示例。
在下文中一共展示了QFileDialog.getOpenFileNames方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_load_bragg_file
# 需要导入模块: from qtpy.QtWidgets import QFileDialog [as 别名]
# 或者: from qtpy.QtWidgets.QFileDialog import getOpenFileNames [as 别名]
def do_load_bragg_file(main_window):
"""
Load Bragg files including GSAS, NeXus, 3-column ASCii.
"""
# get file
ext = 'GSAS (*.gsa *.gda *.gss);;Processed Nexus (*.nxs);;dat (*.dat);;All (*.*)'
# get default dir
if main_window._currDataDir is None:
default_dir = os.getcwd()
else:
default_dir = getDefaultDir(main_window, sub_dir='GSAS')
bragg_file_names = QFileDialog.getOpenFileNames(main_window, 'Choose Bragg File', default_dir, ext)
if isinstance(bragg_file_names, tuple):
bragg_file_names = bragg_file_names[0]
if bragg_file_names is None or bragg_file_names == '' or len(bragg_file_names) == 0:
return
bragg_file_names = [str(bragg_file_name) for bragg_file_name in bragg_file_names]
# update stored data directory
try:
main_window._currDataDir = os.path.split(os.path.abspath(bragg_file_names[0]))[0]
except IndexError as index_err:
err_message = 'Unable to get absolute path of {0} due to {1}'.format(bragg_file_names, index_err)
print(err_message)
check_in_fixed_dir_structure(main_window, sub_dir='GSAS')
# load file
try:
gss_ws_names = list()
for bragg_file_name in bragg_file_names:
gss_ws_name, bank_angles = main_window._myController.load_bragg_file(bragg_file_name)
gss_ws_names.append(gss_ws_name)
banks_list = list()
for i, angle in enumerate(bank_angles):
banks_list.append('Bank {} - {}'.format(i + 1, angle))
# add to tree
main_window.rietveld_ui.treeWidget_braggWSList.add_bragg_ws_group(gss_ws_name, banks_list)
# get plot mode
if len(bragg_file_names) == 1:
main_window.rietveld_ui.graphicsView_bragg.set_to_single_gss(True)
main_window.rietveld_ui.radioButton_multiBank.setChecked(True)
main_window.rietveld_ui.radioButton_multiGSS.setChecked(False)
else:
main_window.rietveld_ui.graphicsView_bragg.set_to_single_gss(False)
main_window.rietveld_ui.radioButton_multiBank.setChecked(False)
main_window.rietveld_ui.radioButton_multiGSS.setChecked(True)
multi_bank_mode = main_window.rietveld_ui.radioButton_multiBank.isChecked()
if multi_bank_mode:
# single-GSS/multi-bank mode
# rename bank
for bank_id in main_window._braggBankWidgets:
bank_check_box = main_window._braggBankWidgets[bank_id]
if bank_id > len(bank_angles) or bank_angles[bank_id - 1] is None:
bank_check_box.setText('Bank %d' % bank_id)
else:
bank_check_box.setText('Bank %.1f' % bank_angles[bank_id - 1])
# END-IF
# END-IF-ELSE
# END-FOR
# clear all previous lines
main_window.rietveld_ui.graphicsView_bragg.reset()
# END-IF
# banks
main_window._onCanvasGSSBankList = get_bragg_banks_selected(main_window)
if len(main_window._onCanvasGSSBankList) == 0:
# select bank 1 as default
main_window._noEventBankWidgets = True
main_window.rietveld_ui.checkBox_bank1.setChecked(True)
main_window._noEventBankWidgets = False
main_window._onCanvasGSSBankList = get_bragg_banks_selected(main_window)
# while in multiple-gss mode, no change will be made on the canvas at all
# prepare to plot new Bragg
plot_data_dict = dict()
for gss_ws_name in gss_ws_names:
plot_data_dict[gss_ws_name] = main_window._onCanvasGSSBankList[:]
# plot
# FIXME/ISSUE/NOW - get a summary on calling to plot_banks
main_window.rietveld_ui.graphicsView_bragg.plot_banks(plot_data_dict, main_window._currBraggXUnit)
# reset unit
reset_bragg_data_range(main_window, main_window._currBraggXUnit)
except RuntimeError as e:
print('Encountered exception')
print(e)
main_window.setStyleSheet("QStatusBar{padding-left:8px;color:red;font-weight:bold;}")
#.........这里部分代码省略.........