本文整理汇总了Python中gui.utils.Colors类的典型用法代码示例。如果您正苦于以下问题:Python Colors类的具体用法?Python Colors怎么用?Python Colors使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Colors类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_color
def set_color(self, color):
if not color:
self.qtcolor = None
self.color = None
Colors.set_widget_color(
self.change_color_button,
Colors.BUTTON_ORIGINAL,
QtImport.QPalette.Button,
)
else:
try:
rgb = color.rgb()
except BaseException:
try:
self.qtcolor = QtImport.QColor(color)
except BaseException:
self.qtcolor = QtImport.QtColor(QtImport.Qt.green)
self.color = self.qtcolor.rgb()
else:
self.color = self.qtcolor.rgb()
else:
self.qtcolor = color
self.color = rgb
Colors.set_widget_color(
self.change_color_button, self.qtcolor, QtImport.QPalette.Button
)
self.parent.cellChanged.emit(self.row, self.col)
示例2: _folder_ledit_change
def _folder_ledit_change(self, new_value):
base_image_dir = self._base_image_dir
base_proc_dir = self._base_process_dir
new_sub_dir = str(new_value).strip(" ")
cursor_pos = self.data_path_layout.folder_ledit.cursorPosition()
if len(new_value) > 0:
available_chars = (
string.ascii_lowercase + string.ascii_uppercase + string.digits + "-_/"
)
if self.enable_macros:
available_chars += "%"
new_value = "".join(i for i in str(new_value) if i in available_chars)
# new_value = new_value.replace("\\", "")
new_sub_dir = str(new_value).strip(" ")
self.data_path_layout.folder_ledit.setText(new_value)
self.data_path_layout.folder_ledit.setCursorPosition(cursor_pos)
if len(new_sub_dir) > 0:
if new_sub_dir[0] == os.path.sep:
new_sub_dir = new_sub_dir[1:]
new_image_directory = os.path.join(base_image_dir, str(new_sub_dir))
new_proc_dir = os.path.join(base_proc_dir, str(new_sub_dir))
else:
new_image_directory = base_image_dir
new_proc_dir = base_proc_dir
self._data_model.directory = new_image_directory
self._data_model.process_directory = new_proc_dir
Colors.set_widget_color(self.data_path_layout.folder_ledit, Colors.WHITE)
self.pathTemplateChangedSignal.emit()
示例3: transmission_state_changed
def transmission_state_changed(self, transmission_state):
"""Updates new value QLineEdit based on the state"""
Colors.set_widget_color(
self.new_value_ledit,
self.STATES.get(transmission_state, Colors.LIGHT_GRAY),
QtImport.QPalette.Base,
)
示例4: step_edited
def step_edited(self, step):
"""Paints step combobox when value is edited
"""
Colors.set_widget_color(
self.step_cbox.lineEdit(),
Colors.LINE_EDIT_CHANGED,
QtImport.QPalette.Button,
)
示例5: user_group_changed
def user_group_changed(self, value):
if self.saved_group:
msg = "User group changed, press set to apply change"
logging.getLogger("GUI").warning(msg)
Colors.set_widget_color(
self.user_group_ledit, Colors.LINE_EDIT_CHANGED, QtImport.QPalette.Base
)
self.saved_group = False
示例6: status_changed
def status_changed(self, status, status_message):
if status:
self.status_label.setText("<b>%s</b>" % status.title())
Colors.set_widget_color(
self.status_label,
DetectorStatusBrick.DETECTOR_STATES.get(status, Colors.LIGHT_GRAY),
)
self.setToolTip(status_message)
示例7: input_field_changed
def input_field_changed(self, input_field_text):
if input_field_text == "":
Colors.set_widget_color(
self.new_value_ledit, Colors.LINE_EDIT_ACTIVE, QtImport.QPalette.Base
)
else:
Colors.set_widget_color(
self.new_value_ledit, Colors.LINE_EDIT_CHANGED, QtImport.QPalette.Base
)
示例8: centring_successful
def centring_successful(self, method, centring_status):
self.centre_button.command_done()
self.accept_button.setEnabled(True)
self.reject_button.setEnabled(True)
if self.inside_data_collection:
Colors.set_widget_color(self.accept_button, Colors.LIGHT_GREEN)
Colors.set_widget_color(self.reject_button, Colors.LIGHT_RED)
self.setEnabled(True)
示例9: centring_failed
def centring_failed(self, method, centring_status):
self.centre_button.command_failed()
self.accept_button.setEnabled(True)
if self.inside_data_collection:
Colors.set_widget_color(self.accept_button, self.standard_color)
self.reject_button.setEnabled(True)
Colors.set_widget_color(self.reject_button, QtImport.Qt.red)
else:
self.reject_button.setEnabled(False)
示例10: login
def login(self):
self.saved_group = False
Colors.set_widget_color(self.user_group_ledit, Colors.WHITE)
self.user_group_ledit.setText("")
self.setEnabled(False)
if not self.login_as_user:
prop_type = str(self.proposal_type_combox.currentText())
prop_number = str(self.proposal_number_ledit.text())
prop_password = str(self.proposal_password_ledit.text())
self.proposal_password_ledit.setText("")
if prop_type == "" and prop_number == "":
if self.local_login_hwobj is None:
return self.refuse_login(False, "Local login not configured.")
try:
locallogin_password = self.local_login_hwobj.password
except AttributeError:
return self.refuse_login(False, "Local login not configured.")
if prop_password != locallogin_password:
return self.refuse_login(None, "Invalid local login password.")
now = time.strftime("%Y-%m-%d %H:%M:S")
prop_dict = {"code": "", "number": "", "title": "", "proposalId": ""}
ses_dict = {
"sessionId": "",
"startDate": now,
"endDate": now,
"comments": "",
}
try:
locallogin_person = self.local_login_hwobj.person
except AttributeError:
locallogin_person = "local user"
pers_dict = {"familyName": locallogin_person}
lab_dict = {"name": "local lab"}
cont_dict = {"familyName": "local contact"}
logging.getLogger().debug(
"ProposalBrick: local login password validated"
)
# return self.accept_login(prop_dict, pers_dict, lab_dict, ses_dict,
# cont_dict)
return self.accept_login(prop_dict, ses_dict)
if api.lims is None:
return self.refuse_login(
False,
"Not connected to the ISPyB database, unable to get proposal.",
)
self._do_login_as_proposal(
prop_type, prop_number, prop_password, api.lims.beamline_name
)
示例11: __init__
def __init__(self, *args):
BaseWidget.__init__(self, *args)
# Properties ----------------------------------------------------------
self.add_property("hwobj_shutter", "string", "")
# Signals -------------------------------------------------------------
# Slots ---------------------------------------------------------------
# Hardware objects ----------------------------------------------------
self.shutter_hwobj = None
# Internal values -----------------------------------------------------
# Graphic elements ----------------------------------------------------
self.main_groupbox = QtImport.QGroupBox("Shutter", self)
self.main_groupbox.setAlignment(QtImport.Qt.AlignCenter)
self.state_label = QtImport.QLabel("<b>unknown</b>", self.main_groupbox)
self.state_label.setAlignment(QtImport.Qt.AlignCenter)
self.state_label.setFixedHeight(24)
Colors.set_widget_color(self.state_label, Colors.LIGHT_GRAY)
_button_widget = QtImport.QWidget(self.main_groupbox)
self.open_button = QtImport.QPushButton(
Icons.load_icon("ShutterOpen"), "Open", _button_widget
)
self.close_button = QtImport.QPushButton(
Icons.load_icon("ShutterClose"), "Close", _button_widget
)
# Layout --------------------------------------------------------------
_button_widget_hlayout = QtImport.QHBoxLayout(_button_widget)
_button_widget_hlayout.addWidget(self.open_button)
_button_widget_hlayout.addWidget(self.close_button)
_button_widget_hlayout.setSpacing(2)
_button_widget_hlayout.setContentsMargins(0, 0, 0, 0)
_main_gbox_vlayout = QtImport.QVBoxLayout(self.main_groupbox)
_main_gbox_vlayout.addWidget(self.state_label)
_main_gbox_vlayout.addWidget(_button_widget)
_main_gbox_vlayout.setSpacing(2)
_main_gbox_vlayout.setContentsMargins(2, 2, 2, 2)
_main_vlayout = QtImport.QVBoxLayout(self)
_main_vlayout.addWidget(self.main_groupbox)
_main_vlayout.setSpacing(0)
_main_vlayout.setContentsMargins(0, 0, 0, 0)
# SizePolicies --------------------------------------------------------
# Qt signal/slot connections ------------------------------------------
self.open_button.clicked.connect(self.open_button_clicked)
self.close_button.clicked.connect(self.close_button_clicked)
示例12: __init__
def __init__(self, *args):
BaseWidget.__init__(self, *args)
# Hardware objects ----------------------------------------------------
# Internal variables --------------------------------------------------
# Properties ----------------------------------------------------------
self.add_property("formatString", "formatString", "###.##")
# Signals ------------------------------------------------------------
# Slots ---------------------------------------------------------------
# Graphic elements ----------------------------------------------------
self.group_box = QtImport.QGroupBox("Transmission", self)
current_label = QtImport.QLabel("Current:", self.group_box)
current_label.setFixedWidth(75)
self.transmission_ledit = QtImport.QLineEdit(self.group_box)
self.transmission_ledit.setReadOnly(True)
set_to_label = QtImport.QLabel("Set to:", self.group_box)
self.new_value_ledit = QtImport.QLineEdit(self.group_box)
# Layout --------------------------------------------------------------
_group_box_gridlayout = QtImport.QGridLayout(self.group_box)
_group_box_gridlayout.addWidget(current_label, 0, 0)
_group_box_gridlayout.addWidget(self.transmission_ledit, 0, 1)
_group_box_gridlayout.addWidget(set_to_label, 1, 0)
_group_box_gridlayout.addWidget(self.new_value_ledit, 1, 1)
_group_box_gridlayout.setSpacing(0)
_group_box_gridlayout.setContentsMargins(1, 1, 1, 1)
_main_vlayout = QtImport.QVBoxLayout(self)
_main_vlayout.setSpacing(0)
_main_vlayout.setContentsMargins(0, 0, 2, 2)
_main_vlayout.addWidget(self.group_box)
# SizePolicies --------------------------------------------------------
# Qt signal/slot connections ------------------------------------------
self.new_value_ledit.returnPressed.connect(self.current_value_changed)
self.new_value_ledit.textChanged.connect(self.input_field_changed)
# Other ---------------------------------------------------------------
Colors.set_widget_color(
self.new_value_ledit, Colors.LINE_EDIT_ACTIVE, QtImport.QPalette.Base
)
self.new_value_validator = QtImport.QDoubleValidator(
0, 100, 2, self.new_value_ledit
)
self.new_value_ledit.setToolTip("Transmission limits 0 : 100 %")
self.instance_synchronize("transmission_ledit", "new_value_ledit")
示例13: connected
def connected(self):
self.setEnabled(True)
tunable_energy = api.energy.can_move_energy()
if tunable_energy is None:
tunable_energy = False
self.set_to_label.setEnabled(tunable_energy)
self.new_value_ledit.setEnabled(tunable_energy)
self.units_combobox.setEnabled(tunable_energy)
if tunable_energy:
Colors.set_widget_color(
self.new_value_ledit, Colors.LINE_EDIT_ACTIVE, QtImport.QPalette.Base
)
示例14: stateChanged
def stateChanged(self, state, state_label=""):
self.setEnabled(True)
state = str(state)
try:
color = self.STATES[state][0]
except KeyError:
state = "unknown"
color = self.STATES[state][0]
if color is None:
color = Colors.GROUP_BOX_GRAY
Colors.set_widget_color(self.state_ledit, color, QtImport.QPalette.Base)
# self.state_ledit.setPaletteBackgroundColor(QColor(color))
if len(state_label) > 0:
self.state_ledit.setText("%s" % state_label)
else:
label_str = state
if state == "in":
prop_label = self["in"].strip()
if len(prop_label.strip()):
label_str = prop_label
if state == "out":
prop_label = self["out"].strip()
if prop_label:
label_str = prop_label
self.state_ledit.setText("%s" % label_str)
if state in self.STATES:
in_enable = self.STATES[state][1]
out_enable = self.STATES[state][2]
else:
in_enable = False
out_enable = False
self.set_in_button.setEnabled(in_enable)
self.set_out_button.setEnabled(out_enable)
if state in self.STATES:
in_state = self.STATES[state][3]
out_state = self.STATES[state][4]
else:
in_state = True
out_state = False
if in_state is not None:
self.set_in_button.blockSignals(True)
self.set_in_button.setChecked(in_state)
self.set_in_button.blockSignals(False)
if out_state is not None:
self.set_out_button.blockSignals(True)
self.set_out_button.setChecked(out_state)
self.set_out_button.blockSignals(False)
"""
示例15: _run_number_ledit_change
def _run_number_ledit_change(self, new_value):
if str(new_value).isdigit():
self._data_model.run_number = int(new_value)
self.data_path_layout.run_number_ledit.setText(str(new_value))
self.update_file_name()
self.pathTemplateChangedSignal.emit()
else:
# self.data_path_layout.run_number_ledit.setText(str(self._data_model.run_number))
Colors.set_widget_color(
self.data_path_layout.folder_ledit, Colors.LIGHT_YELLOW
)