本文整理汇总了Python中qtpy.QtWidgets.QDialog.exec_方法的典型用法代码示例。如果您正苦于以下问题:Python QDialog.exec_方法的具体用法?Python QDialog.exec_怎么用?Python QDialog.exec_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QDialog
的用法示例。
在下文中一共展示了QDialog.exec_方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _ask_overwrite
# 需要导入模块: from qtpy.QtWidgets import QDialog [as 别名]
# 或者: from qtpy.QtWidgets.QDialog import exec_ [as 别名]
def _ask_overwrite(self):
msg = QDialog()
msg.setWindowTitle('Load overwrite')
layout = QGridLayout()
layout.addWidget(QLabel('Instrument %s already exists in memory. Overwrite this?'), 0, 0, 1, -1)
buttons = [QPushButton(label) for label in ['Load and overwrite', 'Cancel Load', 'Load and rename to']]
locations = [[1, 0], [1, 1], [2, 0]]
self.overwrite_flag = 1
def overwriteCB(idx):
self.overwrite_flag = idx
msg.accept()
for idx, button in enumerate(buttons):
button.clicked.connect(lambda _, idx=idx: overwriteCB(idx))
layout.addWidget(button, locations[idx][0], locations[idx][1])
newname = QLineEdit()
newname.editingFinished.connect(lambda: overwriteCB(2))
layout.addWidget(newname, 2, 1)
msg.setLayout(layout)
msg.exec_()
newname = str(newname.text())
if not newname or newname in self.instruments:
self.errormessage('Invalid instrument name. Cancelling load.')
self.overwrite_flag = 1
return self.overwrite_flag, newname
示例2: _build_waverange_dialog
# 需要导入模块: from qtpy.QtWidgets import QDialog [as 别名]
# 或者: from qtpy.QtWidgets.QDialog import exec_ [as 别名]
def _build_waverange_dialog(self, wave_range, line_list):
dialog = QDialog()
loadUi(os.path.join(os.path.dirname(__file__), "ui", "linelists_waverange.ui"), dialog)
# convert from line list native units to whatever units
# are currently being displayed in the spectral axis.
linelist_units = wave_range[0].unit
spectral_axis_unit = self.hub.plot_widget.spectral_axis_unit
w0 = wave_range[0].to(spectral_axis_unit, equivalencies=u.spectral())
w1 = wave_range[1].to(spectral_axis_unit, equivalencies=u.spectral())
# populate labels with correct physical quantity name
dispersion_unit = u.Unit(spectral_axis_unit or "")
if dispersion_unit.physical_type == 'length':
dialog.minwave_label.setText("Minimum wavelength")
dialog.maxwave_label.setText("Maximum wavelength")
elif dispersion_unit.physical_type == 'frequency':
dialog.minwave_label.setText("Minimum frequency")
dialog.maxwave_label.setText("Maximum frequency")
elif dispersion_unit.physical_type == 'energy':
dialog.minwave_label.setText("Minimum energy")
dialog.maxwave_label.setText("Maximum energy")
else:
dialog.minwave_label.setText("Minimum disp. var.")
dialog.maxwave_label.setText("Maximum disp. var.")
# pick a good format to display values represented
# in the currently selected plot units.
if str(w0.unit) in units_formats:
fmt = units_formats[str(w0.unit)]
else:
# use generic formatting for weirder units
fmt = "%.6g"
dialog.min_text.setText(fmt % w0.value)
dialog.max_text.setText(fmt % w1.value)
validator = QDoubleValidator()
validator.setBottom(0.0)
dialog.min_text.setValidator(validator)
dialog.max_text.setValidator(validator)
dialog.nlines_label = self._compute_nlines_in_waverange(line_list, dialog.min_text, dialog.max_text,
dialog.nlines_label, linelist_units, spectral_axis_unit)
dialog.min_text.editingFinished.connect(lambda: self._compute_nlines_in_waverange(line_list,
dialog.min_text,
dialog.max_text,
dialog.nlines_label,
linelist_units,
spectral_axis_unit))
dialog.max_text.editingFinished.connect(lambda: self._compute_nlines_in_waverange(line_list,
dialog.min_text,
dialog.max_text,
dialog.nlines_label,
linelist_units,
spectral_axis_unit))
accepted = dialog.exec_() > 0
amin = amax = None
if accepted:
return self._get_range_from_textfields(dialog.min_text, dialog.max_text,
linelist_units, spectral_axis_unit)
return (amin, amax)