本文整理汇总了Python中qtpy.QtWidgets.QCheckBox.blockSignals方法的典型用法代码示例。如果您正苦于以下问题:Python QCheckBox.blockSignals方法的具体用法?Python QCheckBox.blockSignals怎么用?Python QCheckBox.blockSignals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QCheckBox
的用法示例。
在下文中一共展示了QCheckBox.blockSignals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ColorbarWidget
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import blockSignals [as 别名]
#.........这里部分代码省略.........
self.layout = QVBoxLayout(self)
self.layout.addLayout(self.cmax_layout)
self.layout.addWidget(self.canvas, stretch=1)
self.layout.addLayout(self.cmin_layout)
self.layout.addLayout(self.norm_layout)
self.layout.addWidget(self.autoscale)
def set_mappable(self, mappable):
"""
When a new plot is created this method should be called with the new mappable
"""
self.ax.clear()
self.colorbar = Colorbar(ax=self.ax, mappable=mappable)
self.cmin_value, self.cmax_value = self.colorbar.get_clim()
self.update_clim_text()
self.redraw()
def norm_changed(self):
"""
Called when a different normalization is selected
"""
idx = self.norm.currentIndex()
if NORM_OPTS[idx] == 'Power':
self.powerscale.show()
self.powerscale_label.show()
else:
self.powerscale.hide()
self.powerscale_label.hide()
self.colorbar.mappable.set_norm(self.get_norm())
self.colorbarChanged.emit()
def get_norm(self):
"""
This will create a matplotlib.colors.Normalize from selected idx, limits and powerscale
"""
idx = self.norm.currentIndex()
if self.autoscale.isChecked():
cmin = cmax = None
else:
cmin = self.cmin_value
cmax = self.cmax_value
if NORM_OPTS[idx] == 'Power':
if self.powerscale.hasAcceptableInput():
self.powerscale_value = float(self.powerscale.text())
return PowerNorm(gamma=self.powerscale_value, vmin=cmin, vmax=cmax)
elif NORM_OPTS[idx] == "SymmetricLog10":
return SymLogNorm(1e-8 if cmin is None else max(1e-8, abs(cmin)*1e-3),
vmin=cmin, vmax=cmax)
else:
return Normalize(vmin=cmin, vmax=cmax)
def clim_changed(self):
"""
Called when either the min or max is changed. Will unset the autoscale.
"""
self.autoscale.blockSignals(True)
self.autoscale.setChecked(False)
self.autoscale.blockSignals(False)
self.update_clim()
def update_clim(self):
"""
This will update the clim of the plot based on min, max, and autoscale
"""
if self.autoscale.isChecked():
data = self.colorbar.mappable.get_array()
try:
try:
self.cmin_value = data[~data.mask].min()
self.cmax_value = data[~data.mask].max()
except AttributeError:
self.cmin_value = np.nanmin(data)
self.cmax_value = np.nanmax(data)
except (ValueError, RuntimeWarning):
# all values mask
pass
self.update_clim_text()
else:
if self.cmin.hasAcceptableInput():
self.cmin_value = float(self.cmin.text())
if self.cmax.hasAcceptableInput():
self.cmax_value = float(self.cmax.text())
self.colorbar.set_clim(self.cmin_value, self.cmax_value)
self.redraw()
def update_clim_text(self):
"""
Update displayed limit values based on stored ones
"""
self.cmin.setText("{:.4}".format(self.cmin_value))
self.cmax.setText("{:.4}".format(self.cmax_value))
def redraw(self):
"""
Redraws the colobar and emits signal to cause the parent to redraw
"""
self.colorbar.update_ticks()
self.colorbar.draw_all()
self.canvas.draw_idle()
self.colorbarChanged.emit()
示例2: insert_row
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import blockSignals [as 别名]
def insert_row(self, row=-1,
title='',
sample_runs='',
sample_mass_density='N/A',
sample_chemical_formula='N/A',
packing_fraction='N/A',
align_and_focus_args={},
sample_placzek_arguments={},
normalization_placzek_arguments={}):
self.table_ui.insertRow(row)
self.set_row_height(row, COLUMN_DEFAULT_HEIGHT)
_list_ui_to_unlock = [self.table_ui]
_dimension_widgets = {'label': None, 'value': 'N/A', 'units': None}
_full_dimension_widgets = {'radius': copy.deepcopy(_dimension_widgets),
'radius2': copy.deepcopy(_dimension_widgets),
'height': copy.deepcopy(_dimension_widgets)}
_text_button = {'text': None, 'button': None}
_mass_density_options = {'value': "N/A",
"selected": False}
_mass_density_infos = {'number_density': copy.deepcopy(_mass_density_options),
'mass_density': copy.deepcopy(_mass_density_options),
'mass': copy.deepcopy(_mass_density_options),
'molecular_mass': np.NaN,
'total_number_of_atoms': np.NaN,
}
_material_infos = {'mantid_format': None,
'addie_format': None}
_mass_density_infos['mass_density']["selected"] = True
_master_table_row_ui = {'active': None,
'title': None,
'sample': {'runs': None,
'background': {'runs': None,
'background': None,
},
'material': copy.deepcopy(_text_button),
'material_infos': copy.deepcopy(_material_infos),
'mass_density': copy.deepcopy(_text_button),
'mass_density_infos': copy.deepcopy(_mass_density_infos),
'packing_fraction': None,
'geometry': copy.deepcopy(_full_dimension_widgets),
'shape': None,
'abs_correction': None,
'mult_scat_correction': None,
'inelastic_correction': None,
'placzek_button': None,
'placzek_infos': None,
},
'normalization': {'runs': None,
'background': {'runs': None,
'background': None,
},
'material': copy.deepcopy(_text_button),
'material_infos': copy.deepcopy(_material_infos),
'mass_density': copy.deepcopy(_text_button),
'mass_density_infos': copy.deepcopy(_mass_density_infos),
'packing_fraction': None,
'geometry': copy.deepcopy(_full_dimension_widgets),
'shape': None,
'abs_correction': None,
'mult_scat_correction': None,
'inelastic_correction': None,
'placzek_button': None,
'placzek_infos': None,
},
'align_and_focus_args_button': None,
'align_and_focus_args_infos': {},
}
random_key = self.generate_random_key()
self.key = random_key
# block main table events
self.table_ui.blockSignals(True)
# column 0 (active or not checkBox)
_layout = QHBoxLayout()
_widget = QCheckBox()
_widget.setCheckState(QtCore.Qt.Checked)
_widget.setEnabled(True)
_master_table_row_ui['active'] = _widget
_spacer = QSpacerItem(40, 20,
QSizePolicy.Expanding,
QSizePolicy.Minimum)
_layout.addItem(_spacer)
_layout.addWidget(_widget)
_spacer = QSpacerItem(40, 20,
QSizePolicy.Expanding,
QSizePolicy.Minimum)
_layout.addItem(_spacer)
_layout.addStretch()
_new_widget = QWidget()
_new_widget.setLayout(_layout)
_widget.stateChanged.connect(lambda state=0, key=random_key:
self.main_window.master_table_select_state_changed(state, key))
column = 0
self.table_ui.setCellWidget(row, column, _new_widget)
#.........这里部分代码省略.........