本文整理汇总了Python中qtpy.QtWidgets.QComboBox.currentText方法的典型用法代码示例。如果您正苦于以下问题:Python QComboBox.currentText方法的具体用法?Python QComboBox.currentText怎么用?Python QComboBox.currentText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QComboBox
的用法示例。
在下文中一共展示了QComboBox.currentText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _AcquisitionRasterWidget
# 需要导入模块: from qtpy.QtWidgets import QComboBox [as 别名]
# 或者: from qtpy.QtWidgets.QComboBox import currentText [as 别名]
class _AcquisitionRasterWidget(_AcquisitionWidget):
def _init_ui(self):
# Widgets
self._cb_raster_mode = QComboBox()
self._cb_raster_mode.addItems([None] + list(_RASTER_MODES))
# Layouts
layout = _AcquisitionWidget._init_ui(self)
layout.addRow('Raster mode', self._cb_raster_mode)
# Singals
self._cb_raster_mode.currentIndexChanged.connect(self.edited)
return layout
def parameter(self, parameter=None):
parameter = _AcquisitionWidget.parameter(self, parameter)
parameter.raster_mode = self._cb_raster_mode.currentText()
return parameter
def setParameter(self, condition):
_AcquisitionWidget.setParameter(self, condition)
self._cb_raster_mode.setCurrentIndex(self._cb_raster_mode.findText(condition.raster_mode))
def setReadOnly(self, state):
_AcquisitionWidget.setReadOnly(self, state)
self._cb_raster_mode.setEnabled(not state)
def isReadOnly(self):
return _AcquisitionWidget.isReadOnly(self) and \
not self._cb_raster_mode.isEnabled()
示例2: _CompositionWidget
# 需要导入模块: from qtpy.QtWidgets import QComboBox [as 别名]
# 或者: from qtpy.QtWidgets.QComboBox import currentText [as 别名]
class _CompositionWidget(_ConditionWidget):
def _init_ui(self):
# Widgets
self._cb_unit = QComboBox()
self._cb_unit.addItems(list(_COMPOSITION_UNITS))
# Layouts
layout = _ConditionWidget._init_ui(self)
layout.addRow('<i>Unit</i>', self._cb_unit)
# Signals
self._cb_unit.currentIndexChanged.connect(self.edited)
return layout
def parameter(self, parameter=None):
parameter = _ConditionWidget.parameter(self, parameter)
parameter.unit = self._cb_unit.currentText()
return parameter
def setParameter(self, condition):
_ConditionWidget.setParameter(self, condition)
self._cb_unit.setCurrentIndex(self._cb_unit.findText(condition.unit))
def setReadOnly(self, state):
_ConditionWidget.setReadOnly(self, state)
self._cb_unit.setEnabled(not state)
def isReadOnly(self):
return _ConditionWidget.isReadOnly(self) and \
not self._cb_unit.isEnabled()
示例3: DetectorSpectrometerWidget
# 需要导入模块: from qtpy.QtWidgets import QComboBox [as 别名]
# 或者: from qtpy.QtWidgets.QComboBox import currentText [as 别名]
class DetectorSpectrometerWidget(_DetectorWidget):
def __init__(self, parent=None):
_DetectorWidget.__init__(self, DetectorSpectrometer, parent)
def _init_ui(self):
# Widgets
self._txt_channel_count = NumericalAttributeLineEdit(self.CLASS.channel_count)
self._txt_channel_count.setFormat('{0:d}')
self._wdg_calibration = CalibrationWidget()
self._cb_collection_mode = QComboBox()
self._cb_collection_mode.addItems([None] + list(_COLLECTION_MODES))
# Layout
layout = _DetectorWidget._init_ui(self)
layout.insertRow(0, '<i>Channel count</i>', self._txt_channel_count)
layout.insertRow(1, '<i>Calibration</i>', self._wdg_calibration)
layout.addRow('Collection mode', self._cb_collection_mode)
# Signals
self._txt_channel_count.textEdited.connect(self.edited)
self._wdg_calibration.edited.connect(self.edited)
self._cb_collection_mode.currentIndexChanged.connect(self.edited)
return layout
def _create_parameter(self):
return self.CLASS(1, CalibrationConstant('Quantity', 'm', 0.0))
def parameter(self, parameter=None):
parameter = _DetectorWidget.parameter(self, parameter)
parameter.channel_count = self._txt_channel_count.text()
parameter.calibration = self._wdg_calibration.calibration()
parameter.collection_mode = self._cb_collection_mode.currentText()
return parameter
def setParameter(self, condition):
_DetectorWidget.setParameter(self, condition)
self._txt_channel_count.setText(condition.channel_count)
self._wdg_calibration.setCalibration(condition.calibration)
self._cb_collection_mode.setCurrentIndex(self._cb_collection_mode.findText(condition.collection_mode))
def setReadOnly(self, state):
_DetectorWidget.setReadOnly(self, state)
self._txt_channel_count.setReadOnly(state)
self._wdg_calibration.setReadOnly(state)
self._cb_collection_mode.setEnabled(not state)
def isReadOnly(self):
return _DetectorWidget.isReadOnly(self) and \
self._txt_channel_count.isReadOnly() and \
self._wdg_calibration.isReadOnly() and \
not self._cb_collection_mode.isEnabled()
def hasAcceptableInput(self):
return _DetectorWidget.hasAcceptableInput(self) and \
self._txt_channel_count.hasAcceptableInput() and \
self._wdg_calibration.hasAcceptableInput()
示例4: FontLayout
# 需要导入模块: from qtpy.QtWidgets import QComboBox [as 别名]
# 或者: from qtpy.QtWidgets.QComboBox import currentText [as 别名]
class FontLayout(QGridLayout):
"""Font selection"""
def __init__(self, value, parent=None):
QGridLayout.__init__(self)
font = tuple_to_qfont(value)
assert font is not None
# Font family
self.family = QFontComboBox(parent)
self.family.setCurrentFont(font)
self.addWidget(self.family, 0, 0, 1, -1)
# Font size
self.size = QComboBox(parent)
self.size.setEditable(True)
sizelist = list(range(6, 12)) + list(range(12, 30, 2)) + [36, 48, 72]
size = font.pointSize()
if size not in sizelist:
sizelist.append(size)
sizelist.sort()
self.size.addItems([str(s) for s in sizelist])
self.size.setCurrentIndex(sizelist.index(size))
self.addWidget(self.size, 1, 0)
# Italic or not
self.italic = QCheckBox(_("Italic"), parent)
self.italic.setChecked(font.italic())
self.addWidget(self.italic, 1, 1)
# Bold or not
self.bold = QCheckBox(_("Bold"), parent)
self.bold.setChecked(font.bold())
self.addWidget(self.bold, 1, 2)
def get_font(self):
font = self.family.currentFont()
font.setItalic(self.italic.isChecked())
font.setBold(self.bold.isChecked())
font.setPointSize(int(self.size.currentText()))
return qfont_to_tuple(font)
示例5: ConfigDialog
# 需要导入模块: from qtpy.QtWidgets import QComboBox [as 别名]
# 或者: from qtpy.QtWidgets.QComboBox import currentText [as 别名]
#.........这里部分代码省略.........
is selected and the OK button is disabled. Selecting a framework enables
the OK button.
"""
def __init__(self, frameworks, config, parent=None):
"""
Construct a dialog window.
Parameters
----------
frameworks : dict of (str, type)
Names of all supported frameworks with their associated class
(assumed to be a subclass of RunnerBase)
config : Config
Initial configuration
parent : QWidget
"""
super(ConfigDialog, self).__init__(parent)
self.setWindowTitle(_('Configure tests'))
layout = QVBoxLayout(self)
framework_layout = QHBoxLayout()
framework_label = QLabel(_('Test framework'))
framework_layout.addWidget(framework_label)
self.framework_combobox = QComboBox(self)
for ix, (name, runner) in enumerate(sorted(frameworks.items())):
installed = runner.is_installed()
if installed:
label = name
else:
label = '{} ({})'.format(name, _('not available'))
self.framework_combobox.addItem(label)
self.framework_combobox.model().item(ix).setEnabled(installed)
framework_layout.addWidget(self.framework_combobox)
layout.addLayout(framework_layout)
layout.addSpacing(10)
wdir_label = QLabel(_('Directory from which to run tests'))
layout.addWidget(wdir_label)
wdir_layout = QHBoxLayout()
self.wdir_lineedit = QLineEdit(self)
wdir_layout.addWidget(self.wdir_lineedit)
self.wdir_button = QPushButton(ima.icon('DirOpenIcon'), '', self)
self.wdir_button.setToolTip(_("Select directory"))
self.wdir_button.clicked.connect(lambda: self.select_directory())
wdir_layout.addWidget(self.wdir_button)
layout.addLayout(wdir_layout)
layout.addSpacing(20)
self.buttons = QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel)
layout.addWidget(self.buttons)
self.buttons.accepted.connect(self.accept)
self.buttons.rejected.connect(self.reject)
self.ok_button = self.buttons.button(QDialogButtonBox.Ok)
self.ok_button.setEnabled(False)
self.framework_combobox.currentIndexChanged.connect(
self.framework_changed)
self.framework_combobox.setCurrentIndex(-1)
if config.framework:
index = self.framework_combobox.findText(config.framework)
if index != -1:
self.framework_combobox.setCurrentIndex(index)
self.wdir_lineedit.setText(config.wdir)
@Slot(int)
def framework_changed(self, index):
"""Called when selected framework changes."""
if index != -1:
self.ok_button.setEnabled(True)
def select_directory(self):
"""Display dialog for user to select working directory."""
basedir = to_text_string(self.wdir_lineedit.text())
if not osp.isdir(basedir):
basedir = getcwd()
title = _("Select directory")
directory = getexistingdirectory(self, title, basedir)
if directory:
self.wdir_lineedit.setText(directory)
def get_config(self):
"""
Return the test configuration specified by the user.
Returns
-------
Config
Test configuration
"""
framework = self.framework_combobox.currentText()
if framework == '':
framework = None
return Config(framework=framework, wdir=self.wdir_lineedit.text())
示例6: CSVSettingsDialog
# 需要导入模块: from qtpy.QtWidgets import QComboBox [as 别名]
# 或者: from qtpy.QtWidgets.QComboBox import currentText [as 别名]
class CSVSettingsDialog(QDialog):
def __init__(self, parent=None):
super().__init__(parent)
self.settings = QSettings()
# decimal
self.decimalLabel = QLabel(self.tr("decimal:"))
self.decimalComboBox = QComboBox()
self.decimalLabel.setBuddy(self.decimalComboBox)
self.decimalComboBox.addItems([",", "."])
# separator
self.separatorLabel = QLabel(self.tr("separator:"))
self.separatorComboBox = QComboBox()
self.separatorLabel.setBuddy(self.separatorComboBox)
self.separatorComboBox.addItem("Semicolon ';'", ';')
self.separatorComboBox.addItem("Comma ','", ',')
self.separatorComboBox.addItem("Tabulator '\\t'", '\t')
self.separatorComboBox.addItem("Whitespace ' '", ' ')
# buttons
self.buttons = QDialogButtonBox(
QDialogButtonBox.Ok | QDialogButtonBox.Cancel
)
self.buttons.accepted.connect(self.accept)
self.buttons.rejected.connect(self.reject)
# layout
layout = QGridLayout()
layout.addWidget(self.decimalLabel, 0, 0)
layout.addWidget(self.decimalComboBox, 0, 1)
layout.addWidget(self.separatorLabel, 1, 0)
layout.addWidget(self.separatorComboBox, 1, 1)
layout.addWidget(self.buttons, 2, 0, 1, 2)
self.setLayout(layout)
# settings
self.decimalComboBox.setCurrentIndex(
self.decimalComboBox.findText(
self.settings.value(DECIMAL_SETTING, ","))
)
self.separatorComboBox.setCurrentIndex(
self.separatorComboBox.findData(
self.settings.value(SEPARATOR_SETTING, ";"))
)
self.setWindowTitle(self.tr("record settings"))
def accept(self):
self.settings.setValue(DECIMAL_SETTING, self.decimal)
self.settings.setValue(SEPARATOR_SETTING, self.separator)
super().accept()
# decimal property
@property
def decimal(self):
return self.decimalComboBox.currentText()
# seperator property
@property
def separator(self):
return self.separatorComboBox.itemData(
self.separatorComboBox.currentIndex())
示例7: AcquisitionRasterXYZWidget
# 需要导入模块: from qtpy.QtWidgets import QComboBox [as 别名]
# 或者: from qtpy.QtWidgets.QComboBox import currentText [as 别名]
class AcquisitionRasterXYZWidget(_AcquisitionRasterWidget):
def __init__(self, parent=None):
_AcquisitionRasterWidget.__init__(self, AcquisitionRasterXYZ, parent)
def _init_ui(self):
# Widgets
self._txt_step_count_x = NumericalAttributeLineEdit(self.CLASS.step_count_x)
self._txt_step_count_x.setFormat('{0:d}')
self._txt_step_count_y = NumericalAttributeLineEdit(self.CLASS.step_count_y)
self._txt_step_count_y.setFormat('{0:d}')
self._txt_step_count_z = NumericalAttributeLineEdit(self.CLASS.step_count_z)
self._txt_step_count_z.setFormat('{0:d}')
self._txt_step_size_x = NumericalAttributeLineEdit(self.CLASS.step_size_x)
self._txt_step_size_y = NumericalAttributeLineEdit(self.CLASS.step_size_y)
self._txt_step_size_z = NumericalAttributeLineEdit(self.CLASS.step_size_z)
self._cb_raster_mode_z = QComboBox()
self._cb_raster_mode_z.addItems([None] + list(_RASTER_MODES_Z))
self._cb_location = QComboBox()
self._cb_location.addItems(list(_POSITION_LOCATIONS))
self._wdg_position = SpecimenPositionWidget(inline=True)
# Layouts
layout = _AcquisitionRasterWidget._init_ui(self)
layout.insertRow(0, '<i>Step count (x)</i>', self._txt_step_count_x)
layout.insertRow(1, '<i>Step count (y)</i>', self._txt_step_count_y)
layout.insertRow(2, '<i>Step count (z)</i>', self._txt_step_count_z)
layout.insertRow(3, 'Step size (x)', self._txt_step_size_x)
layout.insertRow(4, 'Step size (y)', self._txt_step_size_y)
layout.insertRow(5, 'Step size (z)', self._txt_step_size_z)
layout.addRow('Raster mode (z)', self._cb_raster_mode_z)
layout.addRow('Position', self._cb_location)
layout.addWidget(self._wdg_position)
# Signals
self._txt_step_count_x.textEdited.connect(self.edited)
self._txt_step_count_y.textEdited.connect(self.edited)
self._txt_step_count_z.textEdited.connect(self.edited)
self._txt_step_size_x.textEdited.connect(self.edited)
self._txt_step_size_y.textEdited.connect(self.edited)
self._txt_step_size_z.textEdited.connect(self.edited)
self._cb_raster_mode_z.currentIndexChanged.connect(self.edited)
self._cb_location.currentIndexChanged.connect(self.edited)
self._wdg_position.edited.connect(self.edited)
return layout
def _create_parameter(self):
return self.CLASS(1, 1, 1)
def parameter(self, parameter=None):
parameter = _AcquisitionRasterWidget.parameter(self, parameter)
parameter.step_count_x = self._txt_step_count_x.text()
parameter.step_count_y = self._txt_step_count_y.text()
parameter.step_count_z = self._txt_step_count_z.text()
parameter.step_size_x = self._txt_step_size_x.text()
parameter.step_size_y = self._txt_step_size_y.text()
parameter.step_size_z = self._txt_step_size_z.text()
parameter.raster_mode_z = self._cb_raster_mode_z.currentText()
parameter.position = (self._wdg_position.condition(),
self._cb_location.currentText())
return parameter
def setParameter(self, condition):
_AcquisitionRasterWidget.setParameter(self, condition)
self._txt_step_count_x.setText(condition.step_count_x)
self._txt_step_count_y.setText(condition.step_count_y)
self._txt_step_count_z.setText(condition.step_count_z)
self._txt_step_size_x.setText(condition.step_size_x)
self._txt_step_size_y.setText(condition.step_size_y)
self._txt_step_size_z.setText(condition.step_size_z)
self._cb_raster_mode_z.setCurrentIndex(self._cb_raster_mode_z.findText(condition.raster_mode_z))
position, location = condition.get_position(True)
self._cb_location.setCurrentIndex(self._cb_location.findText(location))
if position is not None:
self._wdg_position.setParameter(position)
def setReadOnly(self, state):
_AcquisitionRasterWidget.setReadOnly(self, state)
self._txt_step_count_x.setReadOnly(state)
self._txt_step_count_y.setReadOnly(state)
self._txt_step_count_z.setReadOnly(state)
self._txt_step_size_x.setReadOnly(state)
self._txt_step_size_y.setReadOnly(state)
self._txt_step_size_z.setReadOnly(state)
self._cb_raster_mode_z.setEnabled(not state)
self._cb_location.setEnabled(not state)
self._wdg_position.setReadOnly(state)
def isReadOnly(self):
return _AcquisitionRasterWidget.isReadOnly(self) and \
self._txt_step_count_x.isReadOnly() and \
self._txt_step_count_y.isReadOnly() and \
self._txt_step_count_z.isReadOnly() and \
self._txt_step_size_x.isReadOnly() and \
self._txt_step_size_y.isReadOnly() and \
self._txt_step_size_z.isReadOnly() and \
not self._cb_raster_mode_z.isEnabled() and \
not self._cb_location.isEnabled() and \
#.........这里部分代码省略.........
示例8: ItemPropertyDialog
# 需要导入模块: from qtpy.QtWidgets import QComboBox [as 别名]
# 或者: from qtpy.QtWidgets.QComboBox import currentText [as 别名]
#.........这里部分代码省略.........
self.minSpinBox.setRange(-sys.maxsize, sys.maxsize)
self.minLabel.setBuddy(self.minSpinBox)
self.minSpinBox.setValue(self.item.min or 0.0)
# max
self.maxLabel = QLabel(self.tr("maximum:"))
self.maxSpinBox = QDoubleSpinBox()
self.maxSpinBox.setRange(-sys.maxsize, sys.maxsize)
self.maxSpinBox.setValue(self.item.max or 100.0)
# numerator
self.scalefactorLabel = QLabel(self.tr("scalefactor:"))
self.scalefactorSpinBox = NoZerosDoubleSpinBox()
self.scalefactorSpinBox.setRange(-sys.maxsize, sys.maxsize)
self.scalefactorSpinBox.setButtonSymbols(QSpinBox.NoButtons)
self.scalefactorSpinBox.setDecimals(10)
self.scalefactorSpinBox.setValue(self.item.scalefactor or 1)
self.scalefactorLabel.setBuddy(self.scalefactorSpinBox)
# readonly
self.readonlyCheckBox = QCheckBox(self.tr("readonly"))
self.readonlyCheckBox.setChecked(Qt.Checked if self.item.readonly
else Qt.Unchecked)
self.readonlyCheckBox.stateChanged.connect(self.data_changed)
# buttons
self.buttons = QDialogButtonBox(
QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
Qt.Horizontal
)
self.buttons.accepted.connect(self.accept)
self.buttons.rejected.connect(self.reject)
# layout
layout = QGridLayout()
layout.addWidget(self.nameLabel, 0, 0)
layout.addWidget(self.nameLineEdit, 0, 1)
layout.addWidget(self.unitLabel, 1, 0)
layout.addWidget(self.unitLineEdit, 1, 1)
layout.addWidget(self.typeLabel, 2, 0)
layout.addWidget(self.typeComboBox, 2, 1)
layout.addWidget(self.decimalsLabel, 3, 0)
layout.addWidget(self.decimalsSpinBox, 3, 1)
layout.addWidget(self.minLabel, 4, 0)
layout.addWidget(self.minSpinBox, 4, 1)
layout.addWidget(self.maxLabel, 5, 0)
layout.addWidget(self.maxSpinBox, 5, 1)
layout.addWidget(self.scalefactorLabel, 6, 0)
layout.addWidget(self.scalefactorSpinBox, 6, 1)
layout.addWidget(self.readonlyCheckBox, 7, 0, 1, 2)
layout.addWidget(self.buttons, 8, 0, 1, 2)
self.setLayout(layout)
# misc
self.setWindowTitle("Edit JsonItem '%s'" % self.item.key)
self.data_changed()
def accept(self):
self.item.name = self.nameLineEdit.text()
self.item.unit = self.unitLineEdit.text()
self.item.decimals = self.decimalsSpinBox.value()
self.item.min = self.minSpinBox.value()
self.item.max = self.maxSpinBox.value()
self.item.scalefactor = self.scalefactorSpinBox.value()
self.item.readonly = self.readonlyCheckBox.checkState() == Qt.Checked
self.item.type = self.typeComboBox.currentText()
return super().accept()
def data_changed(self):
type_numeric = self.typeComboBox.currentText() not in ('bool', 'str')
type_int = self.typeComboBox.currentText() == 'int'
readonly = self.readonlyCheckBox.checkState() == Qt.Checked
# not used properties invisible
self.decimalsSpinBox.setVisible(type_numeric)
self.decimalsLabel.setVisible(type_numeric)
self.scalefactorSpinBox.setVisible(type_numeric)
self.scalefactorLabel.setVisible(type_numeric)
self.minSpinBox.setVisible(type_numeric and not readonly)
self.minLabel.setVisible(type_numeric and not readonly)
self.maxSpinBox.setVisible(type_numeric and not readonly)
self.maxLabel.setVisible(type_numeric and not readonly)
self.unitLineEdit.setVisible(type_numeric)
self.unitLabel.setVisible(type_numeric)
# no decimals for int
self.minSpinBox.setDecimals(self.decimalsSpinBox.value())
self.maxSpinBox.setDecimals(self.decimalsSpinBox.value())
if type_int:
delta = self.decimalsSpinBox.value() - self.last_decimals
self.scalefactorSpinBox.setValue(
self.scalefactorSpinBox.value() / 10**delta
)
self.last_decimals = self.decimalsSpinBox.value()
示例9: MomentMapsGUI
# 需要导入模块: from qtpy.QtWidgets import QComboBox [as 别名]
# 或者: from qtpy.QtWidgets.QComboBox import currentText [as 别名]
#.........这里部分代码省略.........
# Create calculation label and input box
self.data_label = QLabel("Data:")
self.data_label.setFixedWidth(100)
self.data_label.setAlignment((Qt.AlignRight | Qt.AlignTop))
self.data_label.setFont(boldFont)
self.data_combobox = QComboBox()
self.data_combobox.addItems([str(x).strip() for x in self.data.component_ids() if not x in self.data.coordinate_components])
self.data_combobox.setMinimumWidth(200)
hbl1 = QHBoxLayout()
hbl1.addWidget(self.data_label)
hbl1.addWidget(self.data_combobox)
# Create calculation label and input box
self.order_label = QLabel("Order:")
self.order_label.setFixedWidth(100)
self.order_label.setAlignment((Qt.AlignRight | Qt.AlignTop))
self.order_label.setFont(boldFont)
self.order_combobox = QComboBox()
self.order_combobox.addItems(["1", "2", "3", "4", "5", "6", "7", "8"])
self.order_combobox.setMinimumWidth(200)
hbl2 = QHBoxLayout()
hbl2.addWidget(self.order_label)
hbl2.addWidget(self.order_combobox)
# Create Calculate and Cancel buttons
self.calculateButton = QPushButton("Calculate")
self.calculateButton.clicked.connect(self.calculate_callback)
self.calculateButton.setDefault(True)
self.cancelButton = QPushButton("Cancel")
self.cancelButton.clicked.connect(self.cancel_callback)
hbl5 = QHBoxLayout()
hbl5.addStretch(1)
hbl5.addWidget(self.cancelButton)
hbl5.addWidget(self.calculateButton)
# Add calculation and buttons to popup box
vbl = QVBoxLayout()
vbl.addLayout(hbl1)
vbl.addLayout(hbl2)
vbl.addLayout(hbl5)
self.setLayout(vbl)
self.setMaximumWidth(700)
self.show()
def do_calculation(self, order, data_name):
# Grab spectral-cube
import spectral_cube
cube = spectral_cube.SpectralCube(self.data[data_name], wcs=self.data.coords.wcs)
cube_moment = cube.moment(order=order, axis=0)
self.label = '{}-moment-{}'.format(data_name, order)
# Add new overlay/component to cubeviz. We add this both to the 2D
# container Data object and also as an overlay. In future we might be
# able to use the 2D container Data object for the overlays directly.
add_to_2d_container(self.parent, self.data, cube_moment.value, cube_moment.unit, self.label)
# Going to pass in just the value into the overlay as the units aren't
# currently used for the overlay area. BUT, this is probably not the
# best way to do this.
self.parent.add_overlay(cube_moment.value, self.label, display_now=False)
def calculate_callback(self):
"""
Callback for when they hit calculate
:return:
"""
# Determine the data component and order
order = int(self.order_combobox.currentText())
data_name = self.data_combobox.currentText()
try:
self.do_calculation(order, data_name)
except Exception as e:
show_error_message(str(e), 'Moment Map Error', parent=self)
self.close()
def cancel_callback(self, caller=0):
"""
Cancel callback when the person hits the cancel button
:param caller:
:return:
"""
self.close()
def keyPressEvent(self, e):
if e.key() == Qt.Key_Escape:
self.cancel_callback()
示例10: SerialDialog
# 需要导入模块: from qtpy.QtWidgets import QComboBox [as 别名]
# 或者: from qtpy.QtWidgets.QComboBox import currentText [as 别名]
class SerialDialog(QDialog):
def __init__(self, settings, parent=None):
super().__init__(parent)
self.settings = settings
self.serialports = []
# port
self.portLabel = QLabel(self.tr("COM Port:"))
self.portComboBox = QComboBox()
self.portLabel.setBuddy(self.portComboBox)
self.refresh_comports(self.portComboBox)
# baudrate
self.baudrateLabel = QLabel(self.tr("Baudrate:"))
self.baudrateComboBox = QComboBox()
self.baudrateLabel.setBuddy(self.baudrateComboBox)
for br in BAUDRATES:
self.baudrateComboBox.addItem(str(br), br)
# buttons
self.dlgbuttons = QDialogButtonBox(
QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal)
self.dlgbuttons.rejected.connect(self.reject)
self.dlgbuttons.accepted.connect(self.accept)
# layout
layout = QGridLayout()
layout.addWidget(self.portLabel, 0, 0)
layout.addWidget(self.portComboBox, 0, 1)
layout.addWidget(self.baudrateLabel, 1, 0)
layout.addWidget(self.baudrateComboBox, 1, 1)
layout.addWidget(self.dlgbuttons, 2, 0, 1, 2)
self.setLayout(layout)
self.setWindowTitle(self.tr("Serial Settings"))
# settings
defaults = {
PORT_SETTING: "",
BAUDRATE_SETTING: "115200"
}
self.tmp_settings = ConfigManager()
self.tmp_settings.set_defaults(defaults)
self.tmp_settings.set_many(
{key: self.settings.get(key) for key in defaults.keys()}
)
self.tmp_settings.add_handler(PORT_SETTING, self.portComboBox)
self.tmp_settings.add_handler(BAUDRATE_SETTING, self.baudrateComboBox)
def accept(self):
d = self.tmp_settings.as_dict()
self.settings.set_many(d)
super().accept()
def refresh_comports(self, combobox):
self.serialports = serial_ports()
for port in self.serialports:
combobox.addItem(port)
@property
def port(self):
return self.portComboBox.currentText()
@port.setter
def port(self, value):
if value in self.serialports:
self.portComboBox.setCurrentIndex(
self.portComboBox.findText(value))
else:
raise ValueError("serial port '%s' not available" % value)
@property
def baudrate(self):
return self.baudrateComboBox.currentData()
示例11: ProjectDialog
# 需要导入模块: from qtpy.QtWidgets import QComboBox [as 别名]
# 或者: from qtpy.QtWidgets.QComboBox import currentText [as 别名]
#.........这里部分代码省略.........
# Widget setup
self.combo_python_version.addItems(python_versions)
self.radio_new_dir.setChecked(True)
self.text_location.setEnabled(True)
self.text_location.setReadOnly(True)
self.button_select_location.setIcon(get_std_icon('DirOpenIcon'))
self.button_cancel.setDefault(True)
self.button_cancel.setAutoDefault(True)
self.button_create.setEnabled(False)
self.combo_project_type.addItems(self._get_project_types())
self.combo_python_version.setCurrentIndex(
python_versions.index(current_python_version))
self.setWindowTitle(_('Create new project'))
self.setFixedWidth(500)
self.label_python_version.setVisible(False)
self.combo_python_version.setVisible(False)
# Layouts
layout_top = QHBoxLayout()
layout_top.addWidget(self.radio_new_dir)
layout_top.addWidget(self.radio_from_dir)
layout_top.addStretch(1)
self.groupbox.setLayout(layout_top)
layout_grid = QGridLayout()
layout_grid.addWidget(self.label_project_name, 0, 0)
layout_grid.addWidget(self.text_project_name, 0, 1, 1, 2)
layout_grid.addWidget(self.label_location, 1, 0)
layout_grid.addWidget(self.text_location, 1, 1)
layout_grid.addWidget(self.button_select_location, 1, 2)
layout_grid.addWidget(self.label_project_type, 2, 0)
layout_grid.addWidget(self.combo_project_type, 2, 1, 1, 2)
layout_grid.addWidget(self.label_python_version, 3, 0)
layout_grid.addWidget(self.combo_python_version, 3, 1, 1, 2)
layout = QVBoxLayout()
layout.addWidget(self.groupbox)
layout.addSpacing(10)
layout.addLayout(layout_grid)
layout.addStretch()
layout.addSpacing(20)
layout.addWidget(self.bbox)
self.setLayout(layout)
# Signals and slots
self.button_select_location.clicked.connect(self.select_location)
self.button_create.clicked.connect(self.create_project)
self.button_cancel.clicked.connect(self.close)
self.radio_from_dir.clicked.connect(self.update_location)
self.radio_new_dir.clicked.connect(self.update_location)
self.text_project_name.textChanged.connect(self.update_location)
def _get_project_types(self):
"""Get all available project types."""
project_types = get_available_project_types()
projects = []
for project in project_types:
projects.append(project.PROJECT_TYPE_NAME)
return projects
def select_location(self):
"""Select directory."""
location = osp.normpath(getexistingdirectory(self,
_("Select directory"),
self.location))
if location:
if is_writable(location):
self.location = location
self.update_location()
def update_location(self, text=''):
"""Update text of location."""
self.text_project_name.setEnabled(self.radio_new_dir.isChecked())
name = self.text_project_name.text().strip()
if name and self.radio_new_dir.isChecked():
path = osp.join(self.location, name)
self.button_create.setDisabled(os.path.isdir(path))
elif self.radio_from_dir.isChecked():
self.button_create.setEnabled(True)
path = self.location
else:
self.button_create.setEnabled(False)
path = self.location
self.text_location.setText(path)
def create_project(self):
"""Create project."""
packages = ['python={0}'.format(self.combo_python_version.currentText())]
self.sig_project_creation_requested.emit(
self.text_location.text(),
self.combo_project_type.currentText(),
packages)
self.accept()
示例12: SelectSmoothing
# 需要导入模块: from qtpy.QtWidgets import QComboBox [as 别名]
# 或者: from qtpy.QtWidgets.QComboBox import currentText [as 别名]
#.........这里部分代码省略.........
try:
self.main()
except Exception as e:
info = QMessageBox.critical(self, "Error", str(e))
self.cancel()
raise
def main(self):
"""
Main function to process input and call smoothing function
"""
success = self.input_validation()
if not success:
return
self.hide()
self.abort_window = AbortWindow(self)
QApplication.processEvents()
# Add smoothing parameters
self.smooth_cube.abort_window = self.abort_window
if self.smooth_cube.parent is None and self.parent is not self.smooth_cube:
self.smooth_cube.parent = self.parent
if self.parent is not self.smooth_cube:
self.smooth_cube.data = self.data
self.smooth_cube.smoothing_axis = self.current_axis
self.smooth_cube.kernel_type = self.current_kernel_type
if self.current_kernel_type == "median":
self.smooth_cube.kernel_size = int(self.k_size.text())
else:
self.smooth_cube.kernel_size = float(self.k_size.text())
self.smooth_cube.component_id = str(self.component_combo.currentText())
self.smooth_cube.output_as_component = True
if self.is_preview_active:
self.parent.end_smoothing_preview()
self.is_preview_active = False
self.smooth_cube.multi_threading_smooth()
return
def update_preview_button(self):
if self.parent is None or "spatial" != self.current_axis:
self.previewButton.setDisabled(True)
return
self.previewButton.setDisabled(False)
return
def call_preview(self):
try:
self.preview()
except Exception as e:
info = QMessageBox.critical(self, "Error", str(e))
self.cancel()
raise
def preview(self):
"""Preview current options"""
success = self.input_validation()
if not success:
return
if self.smooth_cube.parent is None and self.parent is not self.smooth_cube:
self.smooth_cube.parent = self.parent
示例13: CondaPackageActionDialog
# 需要导入模块: from qtpy.QtWidgets import QComboBox [as 别名]
# 或者: from qtpy.QtWidgets.QComboBox import currentText [as 别名]
#.........这里部分代码省略.........
layout = QVBoxLayout()
version_layout = QHBoxLayout()
version_layout.addWidget(self.label)
version_layout.addStretch()
version_layout.addWidget(self.widget_version)
layout.addLayout(version_layout)
self.widgets = [self.checkbox, self.button_ok, self.widget_version, self.table_dependencies]
# Create a Table
if action in [C.ACTION_INSTALL, C.ACTION_UPGRADE, C.ACTION_DOWNGRADE]:
table = QTableView(self)
dialog_size = QSize(dialog_size.width() + 40, 300)
self.table_dependencies = table
layout.addWidget(self.checkbox)
self.checkbox.setChecked(True)
self._changed_version(versions[0])
table.setSelectionBehavior(QAbstractItemView.SelectRows)
table.verticalHeader().hide()
table.horizontalHeader().hide()
table.setAlternatingRowColors(True)
table.setShowGrid(False)
table.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
table.horizontalHeader().setStretchLastSection(True)
layout.addWidget(self.table_dependencies)
layout.addWidget(self.bbox)
title = "{0}: {1}".format(action_title[action], name)
self.setLayout(layout)
self.setMinimumSize(dialog_size)
self.setFixedSize(dialog_size)
self.setWindowTitle(title)
self.setModal(True)
# Signals and slots
self.bbox.accepted.connect(self.accept)
self.bbox.rejected.connect(self.close)
self.combobox_version.currentIndexChanged.connect(self._changed_version)
self.checkbox.stateChanged.connect(self._changed_checkbox)
def _changed_version(self, version, dependencies=True):
""" """
self._set_gui_disabled(True)
version = self.combobox_version.currentText()
install_dependencies = self.checkbox.checkState() == Qt.Checked
self._version_text = to_text_string(version)
self._get_dependencies(install_dependencies)
def _get_dependencies(self, dependencies=True):
""" """
package_name = [self._name + "=" + self._version_text]
worker = self.api.conda_dependencies(
prefix=self._prefix, pkgs=package_name, dep=dependencies, channels=self._active_channels
)
worker.sig_finished.connect(self._on_process_finished)
def _changed_checkbox(self, state):
""" """
if state:
self._changed_version(self._version_text)
else:
self._changed_version(self._version_text, dependencies=False)
def _on_process_finished(self, worker, output, error):
""" """
if self.isVisible():
dic = output
self.dependencies_dic = dic
self._set_dependencies_table()
self._set_gui_disabled(False)
def _set_dependencies_table(self):
""" """
table = self.table_dependencies
dic = self.dependencies_dic
table.setModel(CondaDependenciesModel(self, dic, self._packages_sizes))
table.resizeColumnsToContents()
table.resizeRowsToContents()
def _set_gui_disabled(self, value):
""" """
if value:
table = self.table_dependencies
table.setModel(CondaDependenciesModel(self, {}))
table.resizeColumnsToContents()
table.setDisabled(True)
else:
table = self.table_dependencies
table.setDisabled(False)
for widget in self.widgets:
widget.setDisabled(value)
def reject(self):
self.api.conda_terminate()
super(CondaPackageActionDialog, self).reject()
示例14: DetectorSpectrometerXEDSWidget
# 需要导入模块: from qtpy.QtWidgets import QComboBox [as 别名]
# 或者: from qtpy.QtWidgets.QComboBox import currentText [as 别名]
class DetectorSpectrometerXEDSWidget(DetectorSpectrometerWidget):
def __init__(self, parent=None):
_DetectorWidget.__init__(self, DetectorSpectrometerXEDS, parent)
def _init_ui(self):
# Widgets
self._cb_technology = QComboBox()
self._cb_technology.addItems([None] + list(_XEDS_TECHNOLOGIES))
self._txt_nominal_throughput = NumericalAttributeLineEdit(self.CLASS.nominal_throughput)
self._txt_time_constant = NumericalAttributeLineEdit(self.CLASS.time_constant)
self._txt_strobe_rate = NumericalAttributeLineEdit(self.CLASS.strobe_rate)
self._wdg_window = WindowWidget()
# Layout
form = DetectorSpectrometerWidget._init_ui(self)
form.addRow('Technology', self._cb_technology)
form.addRow('Nominal throughput', self._txt_nominal_throughput)
form.addRow('Time constant', self._txt_time_constant)
form.addRow('Strobe rate', self._txt_strobe_rate)
form.addRow('Window', self._wdg_window)
# Signals
self._cb_technology.currentIndexChanged.connect(self.edited)
self._txt_nominal_throughput.textEdited.connect(self.edited)
self._txt_time_constant.textEdited.connect(self.edited)
self._txt_strobe_rate.textEdited.connect(self.edited)
self._wdg_window.edited.connect(self.edited)
return form
def _create_parameter(self):
return self.CLASS(1, CalibrationConstant('Quantity', 'm', 0.0))
def parameter(self, parameter=None):
parameter = DetectorSpectrometerWidget.parameter(self, parameter)
parameter.technology = self._cb_technology.currentText()
parameter.nominal_throughput = self._txt_nominal_throughput.text()
parameter.time_constant = self._txt_time_constant.text()
parameter.strobe_rate = self._txt_strobe_rate.text()
parameter.window = self._wdg_window.window()
return parameter
def setParameter(self, condition):
DetectorSpectrometerWidget.setParameter(self, condition)
self._cb_technology.setCurrentIndex(self._cb_technology.findText(condition.technology))
self._txt_nominal_throughput.setText(condition.nominal_throughput)
self._txt_time_constant.setText(condition.time_constant)
self._txt_strobe_rate.setText(condition.strobe_rate)
self._wdg_window.setWindow(condition.window)
def setReadOnly(self, state):
DetectorSpectrometerWidget.setReadOnly(self, state)
self._cb_technology.setEnabled(not state)
self._txt_nominal_throughput.setReadOnly(state)
self._txt_time_constant.setReadOnly(state)
self._txt_strobe_rate.setReadOnly(state)
self._wdg_window.setReadOnly(state)
def isReadOnly(self):
return DetectorSpectrometerWidget.isReadOnly(self) and \
not self._cb_technology.isEnabled() and \
self._txt_nominal_throughput.isReadOnly() and \
self._txt_time_constant.isReadOnly() and \
self._txt_strobe_rate.isReadOnly() and \
self._wdg_window.isReadOnly()
def hasAcceptableInput(self):
return DetectorSpectrometerWidget.hasAcceptableInput(self) and \
self._txt_nominal_throughput.hasAcceptableInput() and \
self._txt_time_constant.hasAcceptableInput() and \
self._txt_strobe_rate.hasAcceptableInput() and \
self._wdg_window.hasAcceptableInput()
示例15: _DetectorWidget
# 需要导入模块: from qtpy.QtWidgets import QComboBox [as 别名]
# 或者: from qtpy.QtWidgets.QComboBox import currentText [as 别名]
class _DetectorWidget(_ConditionWidget):
def _init_ui(self):
# Widgets
self._cb_signal_type = QComboBox()
self._cb_signal_type.addItems([None] + list(_SIGNAL_TYPES))
self._txt_manufacturer = TextAttributeLineEdit(self.CLASS.manufacturer)
self._txt_model = TextAttributeLineEdit(self.CLASS.model)
self._txt_serial_number = TextAttributeLineEdit(self.CLASS.serial_number)
self._txt_measurement_unit = UnitAttributeLineEdit(self.CLASS.measurement_unit)
self._txt_elevation = NumericalAttributeLineEdit(self.CLASS.elevation)
self._txt_azimuth = NumericalAttributeLineEdit(self.CLASS.azimuth)
self._txt_distance = NumericalAttributeLineEdit(self.CLASS.distance)
self._txt_area = NumericalAttributeLineEdit(self.CLASS.area)
self._txt_solid_angle = NumericalAttributeLineEdit(self.CLASS.solid_angle)
self._txt_semi_angle = NumericalAttributeLineEdit(self.CLASS.semi_angle)
self._txt_temperature = NumericalAttributeLineEdit(self.CLASS.temperature)
# Layout
layout = _ConditionWidget._init_ui(self)
layout.addRow('Type of signal', self._cb_signal_type)
layout.addRow('Manufacturer', self._txt_manufacturer)
layout.addRow('Model', self._txt_model)
layout.addRow('Serial number', self._txt_serial_number)
layout.addRow('Measurement unit', self._txt_measurement_unit)
layout.addRow('Elevation', self._txt_elevation)
layout.addRow('Azimuth', self._txt_azimuth)
layout.addRow('Distance', self._txt_distance)
layout.addRow('Area', self._txt_area)
layout.addRow('Solid angle', self._txt_solid_angle)
layout.addRow('Semi angle', self._txt_semi_angle)
layout.addRow('Temperature', self._txt_temperature)
# Signals
self._cb_signal_type.currentIndexChanged.connect(self.edited)
self._txt_manufacturer.textEdited.connect(self.edited)
self._txt_model.textEdited.connect(self.edited)
self._txt_serial_number.textEdited.connect(self.edited)
self._txt_measurement_unit.textEdited.connect(self.edited)
self._txt_elevation.textEdited.connect(self.edited)
self._txt_azimuth.textEdited.connect(self.edited)
self._txt_distance.textEdited.connect(self.edited)
self._txt_area.textEdited.connect(self.edited)
self._txt_solid_angle.textEdited.connect(self.edited)
self._txt_semi_angle.textEdited.connect(self.edited)
self._txt_temperature.textEdited.connect(self.edited)
return layout
def parameter(self, parameter=None):
parameter = _ConditionWidget.parameter(self, parameter)
parameter.signal_type = self._cb_signal_type.currentText()
parameter.manufacturer = self._txt_manufacturer.text()
parameter.model = self._txt_model.text()
parameter.serial_number = self._txt_serial_number.text()
parameter.measurement_unit = self._txt_measurement_unit.text()
parameter.elevation = self._txt_elevation.text()
parameter.azimuth = self._txt_azimuth.text()
parameter.distance = self._txt_distance.text()
parameter.area = self._txt_area.text()
parameter.solid_angle = self._txt_solid_angle.text()
parameter.semi_angle = self._txt_semi_angle.text()
parameter.temperature = self._txt_temperature.text()
return parameter
def setParameter(self, condition):
_ConditionWidget.setParameter(self, condition)
self._cb_signal_type.setCurrentIndex(self._cb_signal_type.findText(condition.signal_type))
self._txt_manufacturer.setText(condition.manufacturer)
self._txt_model.setText(condition.model)
self._txt_serial_number.setText(condition.serial_number)
self._txt_measurement_unit.setText(condition.measurement_unit)
self._txt_elevation.setText(condition.elevation)
self._txt_azimuth.setText(condition.azimuth)
self._txt_distance.setText(condition.distance)
self._txt_area.setText(condition.area)
self._txt_solid_angle.setText(condition.solid_angle)
self._txt_semi_angle.setText(condition.semi_angle)
self._txt_temperature.setText(condition.temperature)
def setReadOnly(self, state):
_ConditionWidget.setReadOnly(self, state)
self._cb_signal_type.setEnabled(not state)
self._txt_manufacturer.setReadOnly(state)
self._txt_model.setReadOnly(state)
self._txt_serial_number.setReadOnly(state)
self._txt_measurement_unit.setReadOnly(state)
self._txt_elevation.setReadOnly(state)
self._txt_azimuth.setReadOnly(state)
self._txt_distance.setReadOnly(state)
self._txt_area.setReadOnly(state)
self._txt_solid_angle.setReadOnly(state)
self._txt_semi_angle.setReadOnly(state)
self._txt_temperature.setReadOnly(state)
def isReadOnly(self):
return _ConditionWidget.isReadOnly(self) and \
not self._cb_signal_type.isEnabled() and \
self._txt_manufacturer.isReadOnly() and \
self._txt_model.isReadOnly() and \
#.........这里部分代码省略.........