本文整理匯總了Python中qtpy.QtWidgets.QInputDialog.getItem方法的典型用法代碼示例。如果您正苦於以下問題:Python QInputDialog.getItem方法的具體用法?Python QInputDialog.getItem怎麽用?Python QInputDialog.getItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qtpy.QtWidgets.QInputDialog
的用法示例。
在下文中一共展示了QInputDialog.getItem方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: add_other_dialog
# 需要導入模塊: from qtpy.QtWidgets import QInputDialog [as 別名]
# 或者: from qtpy.QtWidgets.QInputDialog import getItem [as 別名]
def add_other_dialog(self):
"""
A QAction callback. Start a dialog to choose a name of a function except a peak or a background. The new
function is added to the browser.
"""
selected_name = QInputDialog.getItem(self.canvas, 'Fit', 'Select function', self.other_names, 0, False)
if selected_name[1]:
self.add_other_requested.emit(selected_name[0])
示例2: add_peak_dialog
# 需要導入模塊: from qtpy.QtWidgets import QInputDialog [as 別名]
# 或者: from qtpy.QtWidgets.QInputDialog import getItem [as 別名]
def add_peak_dialog(self):
"""
A QAction callback. Start a dialog to choose a peak function name. After that the tool will expect the user
to click on the canvas to where the peak should be placed.
"""
selected_name = QInputDialog.getItem(self.canvas, 'Fit', 'Select peak function', self.peak_names,
self.peak_names.index(self.current_peak_type), False)
if selected_name[1]:
self.peak_type_changed.emit(selected_name[0])
self.mouse_state.transition_to('add_peak')
示例3: add_background_dialog
# 需要導入模塊: from qtpy.QtWidgets import QInputDialog [as 別名]
# 或者: from qtpy.QtWidgets.QInputDialog import getItem [as 別名]
def add_background_dialog(self):
"""
A QAction callback. Start a dialog to choose a background function name. The new function is added to the
browser.
"""
current_index = self.background_names.index(self.default_background)
if current_index < 0:
current_index = 0
selected_name = QInputDialog.getItem(self.canvas, 'Fit', 'Select background function', self.background_names,
current_index, False)
if selected_name[1]:
self.add_background_requested.emit(selected_name[0])
示例4: import_data
# 需要導入模塊: from qtpy.QtWidgets import QInputDialog [as 別名]
# 或者: from qtpy.QtWidgets.QInputDialog import getItem [as 別名]
def import_data(self, filenames=None):
"""Import data from text file"""
title = _("Import data")
if filenames is None:
if self.filename is None:
basedir = getcwd()
else:
basedir = osp.dirname(self.filename)
filenames, _selfilter = getopenfilenames(self, title, basedir,
iofunctions.load_filters)
if not filenames:
return
elif is_text_string(filenames):
filenames = [filenames]
for filename in filenames:
self.filename = to_text_string(filename)
ext = osp.splitext(self.filename)[1].lower()
if ext not in iofunctions.load_funcs:
buttons = QMessageBox.Yes | QMessageBox.Cancel
answer = QMessageBox.question(self, title,
_("<b>Unsupported file extension '%s'</b><br><br>"
"Would you like to import it anyway "
"(by selecting a known file format)?"
) % ext, buttons)
if answer == QMessageBox.Cancel:
return
formats = list(iofunctions.load_extensions.keys())
item, ok = QInputDialog.getItem(self, title,
_('Open file as:'),
formats, 0, False)
if ok:
ext = iofunctions.load_extensions[to_text_string(item)]
else:
return
load_func = iofunctions.load_funcs[ext]
# 'import_wizard' (self.setup_io)
if is_text_string(load_func):
# Import data with import wizard
error_message = None
try:
text, _encoding = encoding.read(self.filename)
if self.is_internal_shell:
self.editor.import_from_string(text)
else:
base_name = osp.basename(self.filename)
editor = ImportWizard(self, text, title=base_name,
varname=fix_reference_name(base_name))
if editor.exec_():
var_name, clip_data = editor.get_data()
monitor_set_global(self._get_sock(),
var_name, clip_data)
except Exception as error:
error_message = str(error)
else:
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
QApplication.processEvents()
if self.is_internal_shell:
namespace, error_message = load_func(self.filename)
interpreter = self.shellwidget.interpreter
for key in list(namespace.keys()):
new_key = fix_reference_name(key,
blacklist=list(interpreter.namespace.keys()))
if new_key != key:
namespace[new_key] = namespace.pop(key)
if error_message is None:
interpreter.namespace.update(namespace)
else:
error_message = monitor_load_globals(self._get_sock(),
self.filename, ext)
QApplication.restoreOverrideCursor()
QApplication.processEvents()
if error_message is not None:
QMessageBox.critical(self, title,
_("<b>Unable to load '%s'</b>"
"<br><br>Error message:<br>%s"
) % (self.filename, error_message))
self.refresh_table()
示例5: _open_overplotted_on
# 需要導入模塊: from qtpy.QtWidgets import QInputDialog [as 別名]
# 或者: from qtpy.QtWidgets.QInputDialog import getItem [as 別名]
def _open_overplotted_on(self):
item, ok = QInputDialog.getItem(
self, "Select Tab", "Tab", self._tab_titles, 0, False)
if not ok:
return
self.open.emit(item, self.entries)