本文整理匯總了Python中widgets.widget_utils.DataModelInputBinder.validate_all方法的典型用法代碼示例。如果您正苦於以下問題:Python DataModelInputBinder.validate_all方法的具體用法?Python DataModelInputBinder.validate_all怎麽用?Python DataModelInputBinder.validate_all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類widgets.widget_utils.DataModelInputBinder
的用法示例。
在下文中一共展示了DataModelInputBinder.validate_all方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: DCParametersWidget
# 需要導入模塊: from widgets.widget_utils import DataModelInputBinder [as 別名]
# 或者: from widgets.widget_utils.DataModelInputBinder import validate_all [as 別名]
#.........這裏部分代碼省略.........
self._tree_view_item.setText(0, self._data_collection.get_name())
def _run_number_ledit_change(self, new_value):
if str(new_value).isdigit():
self._data_collection.set_number(int(new_value))
self._tree_view_item.setText(0, self._data_collection.get_name())
def handle_path_conflict(self, widget, new_value):
dc_tree_widget = self._tree_view_item.listView().parent()
dc_tree_widget.check_for_path_collisions()
path_template = self._data_collection.acquisitions[0].path_template
path_conflict = self.queue_model_hwobj.check_for_path_collisions(path_template)
if new_value != "":
if path_conflict:
logging.getLogger("user_level_log").error(
"The current path settings will overwrite data"
+ " from another task. Correct the problem before collecting"
)
widget.setPaletteBackgroundColor(widget_colors.LIGHT_RED)
else:
widget.setPaletteBackgroundColor(widget_colors.WHITE)
def __add_data_collection(self):
return self.add_dc_cb(self._data_collection, self.collection_type)
def mad_energy_selected(self, name, energy, state):
path_template = self._data_collection.acquisitions[0].path_template
if state:
path_template.mad_prefix = name
else:
path_template.mad_prefix = ""
run_number = self._beamline_setup_hwobj.queue_model_hwobj.get_next_run_number(
path_template
)
self.path_widget.set_run_number(run_number)
self.path_widget.set_prefix(path_template.base_prefix)
model = self._tree_view_item.get_model()
model.set_name(path_template.get_prefix())
self._tree_view_item.setText(0, model.get_name())
def tab_changed(self):
if self._tree_view_item:
self.populate_parameter_widget(self._tree_view_item)
def set_enabled(self, state):
self.acq_gbox.setEnabled(state)
self.path_widget.setEnabled(state)
self._processing_gbox.setEnabled(state)
def populate_parameter_widget(self, item):
data_collection = item.get_model()
self._tree_view_item = item
self._data_collection = data_collection
self._acquisition_mib = DataModelInputBinder(
self._data_collection.acquisitions[0].acquisition_parameters
)
# The acq_widget sends a signal to the path_widget, and it relies
# on that both models upto date, we need to refactor this part
# so that both models are set before taking ceratin actions.
# This workaround, works for the time beeing.
self.path_widget._data_model = data_collection.acquisitions[0].path_template
self.acq_widget.set_energies(data_collection.crystal.energy_scan_result)
self.acq_widget.update_data_model(
data_collection.acquisitions[0].acquisition_parameters,
data_collection.acquisitions[0].path_template,
)
self.acq_widget.use_osc_start(True)
self.path_widget.update_data_model(
data_collection.acquisitions[0].path_template
)
self.processing_widget.update_data_model(data_collection.processing_parameters)
if data_collection.acquisitions[
0
].acquisition_parameters.centred_position.snapshot_image:
image = data_collection.acquisitions[
0
].acquisition_parameters.centred_position.snapshot_image
image = image.scale(427, 320)
self.position_widget.child("svideo").setPixmap(qt.QPixmap(image))
invalid = self._acquisition_mib.validate_all()
if invalid:
msg = (
"This data collection has one or more incorrect parameters,"
+ " correct the fields marked in red to solve the problem."
)
logging.getLogger("user_level_log").warning(msg)
示例2: AcquisitionWidget
# 需要導入模塊: from widgets.widget_utils import DataModelInputBinder [as 別名]
# 或者: from widgets.widget_utils.DataModelInputBinder import validate_all [as 別名]
#.........這裏部分代碼省略.........
def set_energies(self, energy_scan_result):
self.acq_widget_layout.child("energies_combo").clear()
inflection = (
("ip: %.4f" % energy_scan_result.inflection)
if energy_scan_result.inflection
else "ip: -"
)
peak = (
("pk: %.4f" % energy_scan_result.peak)
if energy_scan_result.peak
else "pk: -"
)
first_remote = (
("rm1: %.4f" % energy_scan_result.first_remote)
if energy_scan_result.first_remote
else "rm1: -"
)
second_remote = (
("rm2: %.4f" % energy_scan_result.second_remote)
if energy_scan_result.second_remote
else "rm2: -"
)
self.acq_widget_layout.child("energies_combo").insertStrList(
[inflection, peak, first_remote, second_remote]
)
def energy_selected(self, index):
if self.acq_widget_layout.child("mad_cbox").isChecked():
(name, energy) = self.get_mad_energy()
if energy != 0:
self.set_energy(energy, 0)
self.emit(qt.PYSIGNAL("mad_energy_selected"), (name, energy, True))
def set_energy(self, energy, wav):
self._acquisition_parameters.energy = energy
self.acq_widget_layout.child("energy_ledit").setText("%.4f" % float(energy))
def update_transmission(self, transmission):
self.acq_widget_layout.child("transmission_ledit").setText(
"%.2f" % float(transmission)
)
# self._acquisition_parameters.transmission = float(transmission)
def update_resolution(self, resolution):
self.acq_widget_layout.child("resolution_ledit").setText(
"%.3f" % float(resolution)
)
# self._acquisition_parameters.resolution = float(resolution)
def update_data_model(self, acquisition_parameters, path_template):
self._acquisition_parameters = acquisition_parameters
self._path_template = path_template
self._acquisition_mib.set_model(acquisition_parameters)
# Update mad widgets
mad = True if self._path_template.mad_prefix != "" else False
if mad:
mad_prefix = self._path_template.mad_prefix
index = MAD_ENERGY_COMBO_NAMES[mad_prefix]
self.acq_widget_layout.child("energies_combo").setCurrentItem(index)
self.acq_widget_layout.child("mad_cbox").setChecked(True)
self.acq_widget_layout.child("energies_combo").setEnabled(True)
else:
self.acq_widget_layout.child("mad_cbox").setChecked(False)
self.acq_widget_layout.child("energies_combo").setEnabled(False)
self.acq_widget_layout.child("energies_combo").setCurrentItem(0)
def set_tunable_energy(self, state):
self.acq_widget_layout.child("energy_ledit").setEnabled(state)
self.acq_widget_layout.child("mad_cbox").setEnabled(state)
self.acq_widget_layout.child("energies_combo").setEnabled(state)
def disable_inverse_beam(self, state):
if state:
self.acq_widget_layout.child("inverse_beam_cbx").hide()
self.acq_widget_layout.child("subwedge_size_label").hide()
self.acq_widget_layout.child("subwedge_size_ledit").hide()
else:
self.acq_widget_layout.child("inverse_beam_cbx").show()
self.acq_widget_layout.child("subwedge_size_label").show()
self.acq_widget_layout.child("subwedge_size_ledit").show()
def hide_aperture(self, state):
pass
# if state:
# self.acq_widget_layout.child('aperture_ledit').show()
# self.acq_widget_layout.child('aperture_cbox').show()
# else:
# self.acq_widget_layout.child('aperture_ledit').hide()
# self.acq_widget_layout.child('aperture_cbox').hide()
def check_parameter_conflict(self):
return len(self._acquisition_mib.validate_all()) > 0
示例3: AcquisitionWidgetSimple
# 需要導入模塊: from widgets.widget_utils import DataModelInputBinder [as 別名]
# 或者: from widgets.widget_utils.DataModelInputBinder import validate_all [as 別名]
#.........這裏部分代碼省略.........
osc_start_validator = qt.QDoubleValidator(lower, upper, 4, self)
osc_range_validator = qt.QDoubleValidator(lower, upper, 4, self)
else:
osc_start_validator = qt.QDoubleValidator(-10000, 10000, 4, self)
osc_range_validator = qt.QDoubleValidator(-10000, 10000, 4, self)
osc_start_ledit = self.acq_widget_layout.child("osc_start_ledit")
self._acquisition_mib.bind_value_update(
"osc_start", osc_start_ledit, float, osc_start_validator
)
osc_range_ledit = self.acq_widget_layout.child("osc_range_ledit")
self._acquisition_mib.bind_value_update(
"osc_range", osc_range_ledit, float, osc_range_validator
)
if "exposure_time" in limits_dict:
limits = tuple(map(float, limits_dict["exposure_time"].split(",")))
(lower, upper) = limits
exp_time_valdidator = qt.QDoubleValidator(lower, upper, 5, self)
else:
exp_time_valdidator = qt.QDoubleValidator(-0.003, 6000, 5, self)
exp_time_ledit = self.acq_widget_layout.child("exp_time_ledit")
self._acquisition_mib.bind_value_update(
"exp_time", exp_time_ledit, float, exp_time_valdidator
)
self._acquisition_mib.bind_value_update(
"energy",
self.acq_widget_layout.child("energy_ledit"),
float,
qt.QDoubleValidator(0, 1000, 4, self),
)
self._acquisition_mib.bind_value_update(
"transmission",
self.acq_widget_layout.child("transmission_ledit"),
float,
qt.QDoubleValidator(0, 1000, 2, self),
)
self._acquisition_mib.bind_value_update(
"resolution",
self.acq_widget_layout.child("resolution_ledit"),
float,
qt.QDoubleValidator(0, 1000, 3, self),
)
qt.QObject.connect(
self.acq_widget_layout.child("osc_start_cbox"),
qt.SIGNAL("toggled(bool)"),
self.osc_start_cbox_click,
)
te = beamline_setup.tunable_wavelength()
self.set_tunable_energy(te)
has_aperture = self._beamline_setup.has_aperture()
self.hide_aperture(has_aperture)
def set_energy(self, energy, wav):
self._acquisition_parameters.energy = energy
self.acq_widget_layout.child("energy_ledit").setText("%.4f" % float(energy))
def update_transmission(self, transmission):
self.acq_widget_layout.child("transmission_ledit").setText(
"%.2f" % float(transmission)
)
self._acquisition_parameters.transmission = float(transmission)
def update_resolution(self, resolution):
self.acq_widget_layout.child("resolution_ledit").setText(
"%.3f" % float(resolution)
)
self._acquisition_parameters.resolution = float(resolution)
def update_data_model(self, acquisition_parameters, path_template):
self._acquisition_parameters = acquisition_parameters
self._acquisition_mib.set_model(acquisition_parameters)
self._path_template = path_template
self.update_num_images(None, acquisition_parameters.num_images)
def set_tunable_energy(self, state):
self.acq_widget_layout.child("energy_ledit").setEnabled(state)
def hide_aperture(self, state):
if state:
self.acq_widget_layout.child("aperture_ledit").show()
self.acq_widget_layout.child("aperture_cbox").show()
else:
self.acq_widget_layout.child("aperture_ledit").hide()
self.acq_widget_layout.child("aperture_cbox").hide()
def use_osc_start(self, state):
self.acq_widget_layout.child("osc_start_cbox").setChecked(state)
self.acq_widget_layout.child("osc_start_cbox").setDisabled(state)
def check_parameter_conflict(self):
return len(self._acquisition_mib.validate_all()) > 0