37 Commits

Author SHA1 Message Date
Jan Chrin
ca195b0003 README 2026-03-09 12:26:52 +01:00
b66a8657d9 README 2025-10-01 12:10:08 +02:00
e4213dfaee added time.sleep(0.01) to avoid UnicodeDecodeError: 'ascii' codec can't decode byte 0xfa in position 0: ordinal not in range(128) in getCtrlcache in receive_connect_update 2025-05-14 09:55:11 +02:00
13fa5c0f2e added scale_factor for CAQLabel 2024-12-13 15:33:26 +01:00
c0dd0c6038 QEventLoop has int argument not flopat 2024-02-29 17:01:07 +01:00
0f62863828 expt with font size 2024-02-29 16:05:08 +01:00
ab8534c62a expt with font size 2024-02-29 16:03:29 +01:00
9852226d3b expt with font size 2024-02-29 16:01:36 +01:00
434679d9ce expt with font size 2024-02-29 15:58:28 +01:00
f229ba2059 expt with font size 2024-02-29 15:51:16 +01:00
c06bc4f58e expt with font size 2024-02-29 15:48:27 +01:00
3e5255c55e expt with font size 2024-02-29 15:39:20 +01:00
8ae83b2ea6 expt with font size 2024-02-29 15:32:45 +01:00
49be032511 expt with font size 2024-02-29 15:29:56 +01:00
4b5f911c10 expt with font size 2024-02-29 15:19:42 +01:00
727b48e1c6 expt with font size 2024-02-29 15:08:16 +01:00
d997517dc1 expt with font size 2024-02-29 15:04:38 +01:00
68e8da943e expt with font size 2024-02-29 15:01:38 +01:00
bf08fbe488 expt with font size 2024-02-29 14:35:07 +01:00
f335663b55 expt with font size 2024-02-29 14:32:56 +01:00
9829be0bcd expt with font size 2024-02-29 14:30:24 +01:00
14400488a3 Font size to 8 CAQTextEntry 2024-02-29 14:13:32 +01:00
76528ed3c0 Font size to 8 CAQTextEntry 2024-02-29 14:12:03 +01:00
9beed3ff90 Font size to 12 CAQTextEntry 2024-02-29 13:13:11 +01:00
53a0f6495d Font size to 12 CAQTextEntry 2024-02-29 13:11:41 +01:00
fee2e64bb3 Font size to 16 CAQTextEntry 2024-02-29 13:10:22 +01:00
15394066ed Font size to 8 pixels for CAQTextEntry 2024-02-29 13:03:35 +01:00
0441a79305 Font size to 8 pixels for CAQTextEntry 2024-02-29 13:01:39 +01:00
2f0e9aefee Font size to 8 pixels for CAQTextEntry 2024-02-29 12:58:23 +01:00
d148f6777f Font size to 8 pixels for CAQTextEntry 2024-02-29 12:57:20 +01:00
c95afc03b5 Font size to 10 pixels for CAQTextEntry 2024-02-29 12:55:05 +01:00
a830a1a44b Font size to 10 pixels for CAQTextEntry 2024-02-29 12:53:23 +01:00
952cff5002 Font size from 11 to 10 for CAQTextEntry as for CAQLabel 2024-02-29 12:43:19 +01:00
681761ca40 cast to Qt.AlignmentFlag when setAlignment includeds an OR 2024-02-27 15:54:14 +01:00
20b6749ed4 added scale-factot to update_widget in CAQTableWidget 2024-01-30 10:11:46 +01:00
fa33a4479d Added precision to and modified CAQTextEdit 2023-08-21 15:40:32 +02:00
54b332f69d Reconnect btn to 11px 2023-07-27 09:51:46 +02:00
3 changed files with 126 additions and 70 deletions

2
README Normal file
View File

@@ -0,0 +1,2 @@
Qt widgets for PyCafe
RHEL9

View File

@@ -113,7 +113,7 @@ class PVGateway(QWidget):
1000 / self.notify_freq_hz 1000 / self.notify_freq_hz
self.notify_unison = bool(notify_unison) and bool(self.notify_freq_hz) self.notify_unison = bool(notify_unison) and bool(self.notify_freq_hz)
self.parent = parent self.parent = parent
self.settings = self.parent.settings self.settings = self.parent.settings
@@ -584,6 +584,7 @@ class PVGateway(QWidget):
if status == self.cyca.ICAFE_CS_CONN: if status == self.cyca.ICAFE_CS_CONN:
self.initialize_connect = True self.initialize_connect = True
time.sleep(0.01)
self.pv_ctrl = self.cafe.getCtrlCache(self.handle) self.pv_ctrl = self.cafe.getCtrlCache(self.handle)
self.pv_info = self.cafe.getChannelInfo(self.handle) self.pv_info = self.cafe.getChannelInfo(self.handle)
if self.pv_info is not None and self.record_type is None: if self.pv_info is not None and self.record_type is None:
@@ -634,7 +635,7 @@ class PVGateway(QWidget):
DAQ may be in BS mode, but channels within DAQ stream that DAQ may be in BS mode, but channels within DAQ stream that
are not BS enabled will be flagged as CA Mode, i.e., CARead are not BS enabled will be flagged as CA Mode, i.e., CARead
''' '''
_current_qt_dynamic_property = self.qt_dynamic_property_get() _current_qt_dynamic_property = self.qt_dynamic_property_get()
alarm_severity = daq_pvd.alarmSeverity alarm_severity = daq_pvd.alarmSeverity
@@ -708,7 +709,7 @@ class PVGateway(QWidget):
def receive_monitor_dbr_time(self, pvdata, alarm_severity): def receive_monitor_dbr_time(self, pvdata, alarm_severity):
print("called from gateway", self.pv_name, alarm_severity) print("called from gateway", self.pv_name, alarm_severity, flush=True)
pvdata.show() pvdata.show()
def receive_monitor_update(self, value, status, alarm_severity): def receive_monitor_update(self, value, status, alarm_severity):
@@ -765,6 +766,7 @@ class PVGateway(QWidget):
'''Callback function to be invoked on change of pv value. '''Callback function to be invoked on change of pv value.
cafe.getCache and cafe.set operations permitted within callback. cafe.getCache and cafe.set operations permitted within callback.
''' '''
self.mutex.lock() self.mutex.lock()
pv_name = pvname pv_name = pvname
@@ -999,7 +1001,6 @@ class PVGateway(QWidget):
self._qt_readback_color_mode() self._qt_readback_color_mode()
#self.setStatusTip(self.status_tip) #self.setStatusTip(self.status_tip)
elif self.qt_object_name == self.PV_CONTROLLER: elif self.qt_object_name == self.PV_CONTROLLER:
if self.color_mode == self.ACT_ON_BEAM: if self.color_mode == self.ACT_ON_BEAM:
#self.setStatusTip("PV setting acts directly on beam") #self.setStatusTip("PV setting acts directly on beam")
@@ -1008,7 +1009,6 @@ class PVGateway(QWidget):
self.color_mode = self.NOT_ACT_ON_BEAM self.color_mode = self.NOT_ACT_ON_BEAM
#self.setStatusTip("PV setting does not influence beam") #self.setStatusTip("PV setting does not influence beam")
#self._qt_property_selected = #self._qt_property_selected =
self._qt_dynamic_property_set(self.color_mode) self._qt_dynamic_property_set(self.color_mode)

View File

@@ -43,7 +43,7 @@ class QTaggedLineEdit(QWidget):
self.line_edit.setFixedHeight(24) self.line_edit.setFixedHeight(24)
font = QFont("sans serif", 16) font = QFont("sans serif", 16)
fm = QFontMetricsF(font) fm = QFontMetricsF(font)
self.line_edit.setMaximumWidth(fm.width(self.parameter)+20) self.line_edit.setMaximumWidth(int(fm.width(self.parameter)+20))
self.label.setBuddy(self.line_edit) self.label.setBuddy(self.line_edit)
layout = QBoxLayout( layout = QBoxLayout(
QBoxLayout.LeftToRight if position == "LEFT" else \ QBoxLayout.LeftToRight if position == "LEFT" else \
@@ -129,8 +129,8 @@ class CAQLineEdit(QLineEdit, PVGateway):
fm = QFontMetricsF(QFont("Sans Serif", 10)) fm = QFontMetricsF(QFont("Sans Serif", 10))
qrect = fm.boundingRect(self.suggested_text) qrect = fm.boundingRect(self.suggested_text)
_width_scaling_factor = 1.15 _width_scaling_factor = 1.15
self.setFixedHeight((fm.lineSpacing()*1.8)) self.setFixedHeight(int(fm.lineSpacing()*1.8))
self.setFixedWidth(((qrect.width()) * _width_scaling_factor)) self.setFixedWidth(int(qrect.width() * _width_scaling_factor))
if self.pv_within_daq_group: if self.pv_within_daq_group:
self.qt_property_initial_values(qt_object_name=self.PV_DAQ_CA) self.qt_property_initial_values(qt_object_name=self.PV_DAQ_CA)
@@ -163,13 +163,17 @@ class CAQLabel(QLabel, PVGateway):
def __init__(self, parent=None, pv_name: str = "", monitor_callback=None, def __init__(self, parent=None, pv_name: str = "", monitor_callback=None,
pv_within_daq_group: bool = False, color_mode=None, pv_within_daq_group: bool = False, color_mode=None,
show_units: bool = False, prefix: str = "", suffix: str = "", show_units: bool = False, prefix: str = "", suffix: str = "",
notify_freq_hz: int = 0, precision: int = 0): notify_freq_hz: int = 0, precision: int = 0,
scale_factor: float = 1):
super().__init__(parent, pv_name, monitor_callback, pv_within_daq_group, super().__init__(parent, pv_name, monitor_callback, pv_within_daq_group,
color_mode, show_units, prefix, suffix, color_mode, show_units, prefix, suffix,
connect_callback=self.py_connect_callback, connect_callback=self.py_connect_callback,
notify_freq_hz=notify_freq_hz, precision=precision) notify_freq_hz=notify_freq_hz, precision=precision)
self.scale_factor = scale_factor
self.is_initialize_complete() self.is_initialize_complete()
self.configure_widget() self.configure_widget()
@@ -185,12 +189,16 @@ class CAQLabel(QLabel, PVGateway):
@Slot(object, str, int) @Slot(object, str, int)
def receive_daq_update(self, daq_pvd, daq_mode, daq_state): def receive_daq_update(self, daq_pvd, daq_mode, daq_state):
if self.scale_factor != 1:
daq_pvd.value[0] = daq_pvd.value[0] * self.scale_factor
PVGateway.receive_daq_update(self, daq_pvd, daq_mode, daq_state) PVGateway.receive_daq_update(self, daq_pvd, daq_mode, daq_state)
@Slot(str, int, int) @Slot(str, int, int)
@Slot(int, int, int) @Slot(int, int, int)
@Slot(float, int, int) @Slot(float, int, int)
def receive_monitor_update(self, value, status, alarm_severity): def receive_monitor_update(self, value, status, alarm_severity):
if self.scale_factor != 1:
value = value * self.scale_factor
PVGateway.receive_monitor_update(self, value, status, alarm_severity) PVGateway.receive_monitor_update(self, value, status, alarm_severity)
@Slot(int, str, int) @Slot(int, str, int)
@@ -204,9 +212,9 @@ class CAQLabel(QLabel, PVGateway):
fm = QFontMetricsF(QFont("Sans Serif", 10)) fm = QFontMetricsF(QFont("Sans Serif", 10))
qrect = fm.boundingRect(self.suggested_text) qrect = fm.boundingRect(self.suggested_text)
_width_scaling_factor = 1.15 _width_scaling_factor = 1.15
self.setFixedHeight((fm.lineSpacing()*1.8)) self.setFixedHeight(int(fm.lineSpacing()*1.8))
self.setFixedWidth((qrect.width() * _width_scaling_factor)) self.setFixedWidth(int(qrect.width() * _width_scaling_factor))
if self.pv_within_daq_group: if self.pv_within_daq_group:
self.qt_property_initial_values(qt_object_name=self.PV_DAQ_CA) self.qt_property_initial_values(qt_object_name=self.PV_DAQ_CA)
@@ -279,8 +287,8 @@ class CAQMenu(QComboBox, PVGateway):
_width_scaling_factor = 1.1 _width_scaling_factor = 1.1
self.setFixedHeight(fm.lineSpacing()*1.8) self.setFixedHeight(round(fm.lineSpacing()*1.8))
self.setFixedWidth((qrect.width()+40) * _width_scaling_factor) self.setFixedWidth(round((qrect.width()+40) * _width_scaling_factor))
self.qt_property_initial_values(qt_object_name=self.PV_CONTROLLER) self.qt_property_initial_values(qt_object_name=self.PV_CONTROLLER)
@@ -468,8 +476,8 @@ class CAQMessageButton(QPushButton, PVGateway):
_width_scaling_factor = 1.0 _width_scaling_factor = 1.0
self.setText(self.msg_label) self.setText(self.msg_label)
self.setFixedHeight((fm.lineSpacing()*1.8)) self.setFixedHeight(round(fm.lineSpacing()*1.8))
self.setFixedWidth((qrect.width() * _width_scaling_factor)) self.setFixedWidth(round(qrect.width() * _width_scaling_factor))
self.qt_property_initial_values(qt_object_name=self.PV_CONTROLLER) self.qt_property_initial_values(qt_object_name=self.PV_CONTROLLER)
@@ -539,12 +547,14 @@ class CAQTextEntry(QLineEdit, PVGateway):
trigger_monitor = Signal(object, int) trigger_monitor = Signal(object, int)
trigger_connect = Signal(int, str, int) trigger_connect = Signal(int, str, int)
def __init__(self, parent=None, pv_name: str = "", monitor_callback=None, def __init__(self, parent=None, pv_name: str="", monitor_callback=None,
pv_within_daq_group: bool = False, color_mode=None, pv_within_daq_group: bool = False, color_mode=None,
show_units=False, prefix: str = "", suffix: str = ""): show_units=False, prefix: str="", suffix: str="",
precision: int=0):
super().__init__(parent, pv_name, monitor_callback, pv_within_daq_group, super().__init__(parent, pv_name, monitor_callback, pv_within_daq_group,
color_mode, show_units, prefix, suffix, color_mode, show_units, prefix, suffix,
connect_callback=self.py_connect_callback) connect_callback=self.py_connect_callback,
precision=precision)
self.is_initialize_complete() #waits a fraction of a second self.is_initialize_complete() #waits a fraction of a second
@@ -564,8 +574,18 @@ class CAQTextEntry(QLineEdit, PVGateway):
@Slot(int, int, int) @Slot(int, int, int)
@Slot(float, int, int) @Slot(float, int, int)
def receive_monitor_update(self, value, status, alarm_severity): def receive_monitor_update(self, value, status, alarm_severity):
#print ("FONT-1", self.font().pixelSize(), value)
#print ("FONT-1", self.font().pointSize(), value)
#self.setFont(QFont("Sans Serif", 8))
#QLineEdit.setFont(self, QFont("Sans Serif", 8))
#self.font().setPixelSize(12)
#QLineEdit.font().setPixelSize(8)
PVGateway.receive_monitor_update(self, value, status, alarm_severity) PVGateway.receive_monitor_update(self, value, status, alarm_severity)
#self.font().setPixelSize(12)
#print ("FONT-3", self.font().pixelSize(), value)
#print ("FONT-3", self.font().pointSize(), value)
@Slot(int, str, int) @Slot(int, str, int)
def receive_connect_update(self, handle: int, pv_name: str, status: int): def receive_connect_update(self, handle: int, pv_name: str, status: int):
'''Triggered by connect signal''' '''Triggered by connect signal'''
@@ -573,14 +593,20 @@ class CAQTextEntry(QLineEdit, PVGateway):
def configure_widget(self): def configure_widget(self):
self.setFocusPolicy(Qt.StrongFocus) self.setFocusPolicy(Qt.StrongFocus)
#self.setFont(QFont("Sans Serif", 12))
fm = QFontMetricsF(QFont("Sans Serif", 12)) #QLineEdit.setFont(self, QFont("Sans Serif", 8))
#f = QFont("Sans Serif")
#f.setPixelSize(11)
#self.setFont(f)
#fm = QFontMetricsF(f)
#As for CAQLabel
QLineEdit.setFont(self, QFont("Sans Serif", 12))
fm = QFontMetricsF(QFont("Sans Serif", 9))
qrect = fm.boundingRect(self.suggested_text) qrect = fm.boundingRect(self.suggested_text)
_width_scaling_factor = 1.2
_width_scaling_factor = 1.15
self.setFixedHeight(round(fm.lineSpacing()*1.8))
self.setFixedHeight((fm.lineSpacing()*1.8)) self.setFixedWidth(round(qrect.width()+20 * _width_scaling_factor))
self.setFixedWidth(((qrect.width()+10) * _width_scaling_factor))
self.qt_property_initial_values(qt_object_name=self.PV_CONTROLLER) self.qt_property_initial_values(qt_object_name=self.PV_CONTROLLER)
@@ -598,7 +624,7 @@ class CAQTextEntry(QLineEdit, PVGateway):
else: else:
valStr = ("{: .%sf}" % self.precision) valStr = ("{: .%sf}" % self.precision)
strText = valStr.format(round(val, self.precision)) strText = valStr.format(round(val, self.precision))
print(strText, " precision ", self.precision) #print(strText, " precision ", self.precision)
self.setText(strText) self.setText(strText)
else: else:
#Do this for TextInfo cache #Do this for TextInfo cache
@@ -608,6 +634,9 @@ class CAQTextEntry(QLineEdit, PVGateway):
def setText(self, value): def setText(self, value):
QLineEdit.setText(self, value) QLineEdit.setText(self, value)
self.currentText = self.text() self.currentText = self.text()
#print ("FONT-2", self.font().pixelSize(), value)
#print ("FONT-2", self.font().pointSize(), value)
def enterEvent(self, event): def enterEvent(self, event):
if self.pv_info is not None: if self.pv_info is not None:
@@ -643,7 +672,7 @@ class CAQTextEntry(QLineEdit, PVGateway):
class CAQSpinBox(QSpinBox, PVGateway): class CAQSpinBox(QSpinBox, PVGateway):
'''Channel access enabled QTextEntry widget''' '''Channel access enabled QSpinBox widget'''
trigger_monitor_float = Signal(float, int, int) trigger_monitor_float = Signal(float, int, int)
trigger_monitor_int = Signal(int, int, int) trigger_monitor_int = Signal(int, int, int)
trigger_monitor_str = Signal(str, int, int) trigger_monitor_str = Signal(str, int, int)
@@ -712,8 +741,8 @@ class CAQSpinBox(QSpinBox, PVGateway):
qrect = fm.boundingRect(_suggested_text) qrect = fm.boundingRect(_suggested_text)
_width_scaling_factor = 1.0 _width_scaling_factor = 1.0
self.setFixedHeight((fm.lineSpacing()*1.8)) self.setFixedHeight(int(fm.lineSpacing()*1.8))
self.setFixedWidth(((qrect.width()) * _width_scaling_factor)) self.setFixedWidth(int(qrect.width() * _width_scaling_factor))
self.qt_property_initial_values(qt_object_name=self.PV_CONTROLLER) self.qt_property_initial_values(qt_object_name=self.PV_CONTROLLER)
@@ -933,8 +962,8 @@ class CAQDoubleSpinBox(QDoubleSpinBox, PVGateway):
_width_scaling_factor = 1.15 _width_scaling_factor = 1.15
self.setFixedHeight((fm.lineSpacing()*1.8)) self.setFixedHeight(int(fm.lineSpacing()*1.8))
self.setFixedWidth(((qrect.width()) * _width_scaling_factor)) self.setFixedWidth(int(qrect.width() * _width_scaling_factor))
self.qt_property_initial_values(qt_object_name=self.PV_CONTROLLER) self.qt_property_initial_values(qt_object_name=self.PV_CONTROLLER)
@@ -1211,7 +1240,7 @@ class CAQTableWidget(QTableWidget):
def widget_update(self): def widget_update(self):
""" Called when self.notif_unison is True """
for _row, pvgate in enumerate(self.pv_gateway): for _row, pvgate in enumerate(self.pv_gateway):
if not pvgate.notify_unison: if not pvgate.notify_unison:
@@ -1229,6 +1258,8 @@ class CAQTableWidget(QTableWidget):
#if timestamps the same - then skip #if timestamps the same - then skip
_value = _pvd.value[0] _value = _pvd.value[0]
if self.scale_factor != 1:
_value = _value * self.scale_factor
_value = pvgate.format_display_value(_value) _value = pvgate.format_display_value(_value)
qtwi = QTableWidgetItem(str(_value)+ " ") qtwi = QTableWidgetItem(str(_value)+ " ")
@@ -1242,8 +1273,8 @@ class CAQTableWidget(QTableWidget):
self.setItem(_row, val_col_no, self.setItem(_row, val_col_no,
QTableWidgetItem(qtwi)) QTableWidgetItem(qtwi))
self.item(_row, val_col_no).setTextAlignment(Qt.AlignRight | self.item(_row, val_col_no).setTextAlignment(
Qt.AlignVCenter) Qt.AlignmentFlag(Qt.AlignRight|Qt.AlignVCenter))
_ts_date = _pvd.tsDateAsString _ts_date = _pvd.tsDateAsString
_ts_str_len = len(_ts_date) _ts_str_len = len(_ts_date)
@@ -1304,6 +1335,8 @@ class CAQTableWidget(QTableWidget):
self.item(_row, val_col_no).setBackground( self.item(_row, val_col_no).setBackground(
QColor(pvgate.bg_readback)) QColor(pvgate.bg_readback))
#self.item(_row, val_col_no).setBackground(
# QColor('#aeae66'))
if self.show_timestamp: if self.show_timestamp:
self.item(_row, ts_col_no).setBackground( self.item(_row, ts_col_no).setBackground(
QColor(pvgate.bg_readback)) QColor(pvgate.bg_readback))
@@ -1382,7 +1415,7 @@ class CAQTableWidget(QTableWidget):
self.notify_freq_hz = abs(notify_freq_hz) self.notify_freq_hz = abs(notify_freq_hz)
self.notify_freq_hz_default = self.notify_freq_hz self.notify_freq_hz_default = self.notify_freq_hz
self.notify_milliseconds = 0 if self.notify_freq_hz == 0 else \ self.notify_milliseconds = 0 if self.notify_freq_hz == 0 else \
1000 / self.notify_freq_hz int(1000 / self.notify_freq_hz)
self.notify_unison = bool(notify_unison) and bool(self.notify_freq_hz) self.notify_unison = bool(notify_unison) and bool(self.notify_freq_hz)
@@ -1435,6 +1468,7 @@ class CAQTableWidget(QTableWidget):
connect_triggers=False, notify_freq_hz=self.notify_freq_hz, connect_triggers=False, notify_freq_hz=self.notify_freq_hz,
notify_unison=self.notify_unison, precision=self.precision) notify_unison=self.notify_unison, precision=self.precision)
self.pv_gateway[i].is_initialize_complete() self.pv_gateway[i].is_initialize_complete()
self.pv_gateway[i].trigger_connect.connect( self.pv_gateway[i].trigger_connect.connect(
self.receive_connect_update) self.receive_connect_update)
@@ -1554,7 +1588,7 @@ class CAQTableWidget(QTableWidget):
time.sleep(self.set_delay) time.sleep(self.set_delay)
##self.standby_value_button.setEnabled(False) ##self.standby_value_button.setEnabled(False)
#QApplication.sendPostedEvents() #QApplication.sendPostedEvents()
QApplication.processEvents(QEventLoop.AllEvents, 1.0) QApplication.processEvents(QEventLoop.AllEvents, 1)
if status != self.cyca.ICAFE_NORMAL: if status != self.cyca.ICAFE_NORMAL:
_mess = ("The following devices reported an error " + _mess = ("The following devices reported an error " +
@@ -1631,7 +1665,7 @@ class CAQTableWidget(QTableWidget):
if status_list[i] != self.cyca.ICAFE_NORMAL: if status_list[i] != self.cyca.ICAFE_NORMAL:
status = status_list[i] status = status_list[i]
time.sleep(self.set_delay) time.sleep(self.set_delay)
QApplication.processEvents(QEventLoop.AllEvents, 1.0) QApplication.processEvents(QEventLoop.AllEvents, 1)
if status != self.cyca.ICAFE_NORMAL: if status != self.cyca.ICAFE_NORMAL:
_mess = ("The following device(s) reported an error " + _mess = ("The following device(s) reported an error " +
@@ -1766,8 +1800,8 @@ class CAQTableWidget(QTableWidget):
_f.setPointSize(8) _f.setPointSize(8)
qtwi.setFont(_f) qtwi.setFont(_f)
self.setItem(_row, _column_no, qtwi) self.setItem(_row, _column_no, qtwi)
self.item(_row, _column_no).setTextAlignment(Qt.AlignRight | self.item(_row, _column_no).setTextAlignment(
Qt.AlignVCenter) Qt.AlignmentFlag(Qt.AlignRight|Qt.AlignVCenter))
def set_init_values(self, values): def set_init_values(self, values):
@@ -1786,9 +1820,9 @@ class CAQTableWidget(QTableWidget):
_f.setPointSize(8) _f.setPointSize(8)
qtwi.setFont(_f) qtwi.setFont(_f)
self.setItem(_row, _column_no, qtwi) self.setItem(_row, _column_no, qtwi)
self.item(_row, _column_no).setTextAlignment(Qt.AlignRight | self.item(_row, _column_no).setTextAlignment(
Qt.AlignVCenter) Qt.AlignmentFlag(Qt.AlignRight|Qt.AlignVCenter))
def update_init_values(self): def update_init_values(self):
_start = 0 _start = 0
@@ -1800,8 +1834,7 @@ class CAQTableWidget(QTableWidget):
return return
for _row in range(_start, _end): for _row in range(_start, _end):
_handle = self.pv_gateway[_row].handle _handle = self.pv_gateway[_row].handle
_value = self.pv_gateway[_row].cafe.getCache(_handle) _value = self.pv_gateway[_row].cafe.getCache(_handle)
@@ -1816,9 +1849,10 @@ class CAQTableWidget(QTableWidget):
qtwi.setFont(_f) qtwi.setFont(_f)
self.setItem(_row, _column_no, qtwi) self.setItem(_row, _column_no, qtwi)
self.item(_row, _column_no).setTextAlignment(Qt.AlignRight | self.item(_row, _column_no).setTextAlignment(
Qt.AlignVCenter) Qt.AlignmentFlag(Qt.AlignRight|Qt.AlignVCenter))
def configure_widget(self): def configure_widget(self):
@@ -1858,15 +1892,15 @@ class CAQTableWidget(QTableWidget):
f.setPointSize(8) f.setPointSize(8)
qtwt.setFont(f) qtwt.setFont(f)
self.setItem(i, _pv_column, qtwt) self.setItem(i, _pv_column, qtwt)
self.item(i, _pv_column).setTextAlignment(Qt.AlignHCenter | self.item(i, _pv_column).setTextAlignment(
Qt.AlignVCenter) Qt.AlignmentFlag(Qt.AlignHCenter|Qt.AlignVCenter))
else: else:
istart = 0 istart = 0
for i_column in range(istart, self.no_columns-1): for i_column in range(istart, self.no_columns-1):
self.setItem(i, i_column, QTableWidgetItem(str(""))) self.setItem(i, i_column, QTableWidgetItem(str("")))
self.item(i, i_column).setTextAlignment(Qt.AlignHCenter | self.item(i, i_column).setTextAlignment(
Qt.AlignVCenter) Qt.AlignmentFlag(Qt.AlignHCenter|Qt.AlignVCenter))
self.pv2item_dict[self.pv_gateway[i]] = i self.pv2item_dict[self.pv_gateway[i]] = i
cb_item = QTableWidgetItem() cb_item = QTableWidgetItem()
@@ -1899,7 +1933,8 @@ class CAQTableWidget(QTableWidget):
if 'PV' in self.columns_dict: if 'PV' in self.columns_dict:
self.setCellWidget(len(self.pv_gateway), 0, self.init_widget) self.setCellWidget(len(self.pv_gateway), 0, self.init_widget)
else: else:
self.setCellWidget(len(self.pv_gateway), self.columns_dict['Init'], self.init_widget) self.setCellWidget(len(self.pv_gateway),
self.columns_dict['Init'], self.init_widget)
self.restore_widget = QWidget() self.restore_widget = QWidget()
self.restore_layout = QHBoxLayout(self.restore_widget) self.restore_layout = QHBoxLayout(self.restore_widget)
@@ -1942,7 +1977,8 @@ class CAQTableWidget(QTableWidget):
_standby_layout.setAlignment(Qt.AlignCenter) _standby_layout.setAlignment(Qt.AlignCenter)
_standby_layout.setContentsMargins(1, 1, 0, 0) _standby_layout.setContentsMargins(1, 1, 0, 0)
_standby_widget.setLayout(_standby_layout) _standby_widget.setLayout(_standby_layout)
self.setCellWidget(len(self.pv_gateway), self.columns_dict['Standby'], _standby_widget) self.setCellWidget(len(self.pv_gateway),
self.columns_dict['Standby'], _standby_widget)
#Do not display no for last row (Reconnect button) #Do not display no for last row (Reconnect button)
@@ -1957,7 +1993,7 @@ class CAQTableWidget(QTableWidget):
f = self.reconnect_button.font() f = self.reconnect_button.font()
if 'Timestamp' in self.columns_dict.keys(): if 'Timestamp' in self.columns_dict.keys():
f.setPixelSize(13) f.setPixelSize(11) #previous 13
self.reconnect_button.setFixedWidth(100) self.reconnect_button.setFixedWidth(100)
else: else:
f.setPixelSize(11) #6 f.setPixelSize(11) #6
@@ -2050,8 +2086,8 @@ class CAQTableWidget(QTableWidget):
for i_column in range(istart, self.no_columns-2): for i_column in range(istart, self.no_columns-2):
self.item(_row, i_column).setForeground(QColor("#000000")) self.item(_row, i_column).setForeground(QColor("#000000"))
self.item(_row, i_column).setTextAlignment(Qt.AlignRight | self.item(_row, i_column).setTextAlignment(
Qt.AlignVCenter) Qt.AlignmentFlag(Qt.AlignRight|Qt.AlignVCenter))
self.item(_row, self.columns_dict['Value']).setBackground( self.item(_row, self.columns_dict['Value']).setBackground(
QColor("#ffffff")) QColor("#ffffff"))
@@ -2084,15 +2120,26 @@ class CAQTableWidget(QTableWidget):
if self.scale_factor != 1: if self.scale_factor != 1:
value = value * self.scale_factor value = value * self.scale_factor
_value = self.pv_gateway[_row].format_display_value(value) _value = self.pv_gateway[_row].format_display_value(value)
#if 'QMD10' in self.pv_gateway[_row].pv_name:
# print(_value + " from widgets.py" + self.pv_gateway[_row].pv_name)
qtwi = QTableWidgetItem(str(_value) + " ") qtwi = QTableWidgetItem(str(_value) + " ")
f = qtwi.font() f = qtwi.font()
f.setPointSize(8) f.setPointSize(8)
qtwi.setFont(f) qtwi.setFont(f)
qtwi.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)
#qtwi.setEditTriggers(QAbstractItemView.AllEditTriggers)
self.setItem(_row, self.columns_dict['Value'], qtwi) self.setItem(_row, self.columns_dict['Value'], qtwi)
#self.item(_row, self.columns_dict['Value']).setFlags(
#Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)
#self.item(_row, self.columns_dict['Value']).setEditTriggers(
#QAbstractItemView.AllEditTriggers)
self.item(_row, self.columns_dict['Value']).setTextAlignment( self.item(_row, self.columns_dict['Value']).setTextAlignment(
Qt.AlignRight | Qt.AlignVCenter) Qt.AlignmentFlag(Qt.AlignRight|Qt.AlignVCenter))
if 'Timestamp' in self.columns_dict.keys(): if 'Timestamp' in self.columns_dict.keys():
_handle = self.pv_gateway[_row].handle _handle = self.pv_gateway[_row].handle
_pvd = self.pv_gateway[_row].cafe.getPVCache(_handle) _pvd = self.pv_gateway[_row].cafe.getPVCache(_handle)
@@ -2128,6 +2175,8 @@ class CAQTableWidget(QTableWidget):
_prop = self.pv_gateway[_row].qt_dynamic_property_get() _prop = self.pv_gateway[_row].qt_dynamic_property_get()
if _prop == self.pv_gateway[_row].READBACK_ALARM: if _prop == self.pv_gateway[_row].READBACK_ALARM:
if alarm_severity == self.pv_gateway[_row].cyca.SEV_MAJOR: if alarm_severity == self.pv_gateway[_row].cyca.SEV_MAJOR:
@@ -2172,6 +2221,11 @@ class CAQTableWidget(QTableWidget):
elif _prop == self.pv_gateway[_row].READBACK_STATIC: elif _prop == self.pv_gateway[_row].READBACK_STATIC:
self.item(_row, self.columns_dict['Value']).setBackground( self.item(_row, self.columns_dict['Value']).setBackground(
QColor(self.pv_gateway[_row].bg_readback)) QColor(self.pv_gateway[_row].bg_readback))
#self.item(_row, self.columns_dict['Value']).setBackground(
# QColor("#ffffe1"))
#self.item(_row, self.columns_dict['Value']).setFlags(
#Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)
if 'Timestamp' in self.columns_dict.keys(): if 'Timestamp' in self.columns_dict.keys():
self.item(_row, self.columns_dict['Timestamp']).setBackground( self.item(_row, self.columns_dict['Timestamp']).setBackground(
QColor(self.pv_gateway[_row].bg_readback)) QColor(self.pv_gateway[_row].bg_readback))
@@ -2555,7 +2609,7 @@ class QResultsWidget:
qlabel.setFont(_font) qlabel.setFont(_font)
qlabel.setStyleSheet(("QLabel{color:black;" + qlabel.setStyleSheet(("QLabel{color:black;" +
"margin:0px; padding:2px;}")) "margin:0px; padding:2px;}"))
qlabel.setFixedWidth(qrect1.width() * _width_scaling_factor) qlabel.setFixedWidth(int(qrect1.width() * _width_scaling_factor))
qlabel.setFixedHeight(_widget_height) qlabel.setFixedHeight(_widget_height)
qle.setFocusPolicy(Qt.NoFocus) qle.setFocusPolicy(Qt.NoFocus)
@@ -2564,7 +2618,7 @@ class QResultsWidget:
"background-color: lightgray;" + "background-color: lightgray;" +
"qproperty-readOnly: true;" + "qproperty-readOnly: true;" +
"margin:0px; padding:2px;}")) "margin:0px; padding:2px;}"))
qle.setFixedWidth(qrect2.width() * _width_scaling_factor_le) qle.setFixedWidth(int(qrect2.width() * _width_scaling_factor_le))
qle.setFixedHeight(_widget_height) qle.setFixedHeight(_widget_height)
qle.setAlignment(Qt.AlignRight) qle.setAlignment(Qt.AlignRight)
@@ -2629,13 +2683,13 @@ class QResultsWidget:
table.resizeColumnsToContents() table.resizeColumnsToContents()
table.resizeRowsToContents() table.resizeRowsToContents()
table.setFixedHeight((fm.lineSpacing() * _factor * len( table.setFixedHeight(int(fm.lineSpacing() * _factor * len(
self.table_dict)) + fm.lineSpacing()*2) self.table_dict)) + fm.lineSpacing()*2)
table.setFixedWidth(((qrect.width()) * _width_scaling_factor)) table.setFixedWidth(int(qrect.width() * _width_scaling_factor))
_vbox2.addWidget(table) _vbox2.addWidget(table)
_vbox2.setAlignment(Qt.AlignCenter|Qt.AlignTop) _vbox2.setAlignment(Qt.AlignmentFlag(Qt.AlignCenter|Qt.AlignTop))
_vbox2_widget.setLayout(_vbox2) _vbox2_widget.setLayout(_vbox2)
_vbox.addWidget(_vbox2_widget) _vbox.addWidget(_vbox2_widget)
@@ -2643,9 +2697,9 @@ class QResultsWidget:
self._group_box.setLayout(_vbox) self._group_box.setLayout(_vbox)
self._group_box.setContentsMargins(20, 20, 20, 20) self._group_box.setContentsMargins(20, 20, 20, 20)
self._group_box.setAlignment(Qt.AlignTop) self._group_box.setAlignment(Qt.AlignTop)
self._group_box.setFixedHeight( self._group_box.setFixedHeight(int(
table.height() + (_widget_height*len(self.summary_dict))) table.height() + (_widget_height*len(self.summary_dict))))
self._group_box.setFixedWidth(table.width() + 20) self._group_box.setFixedWidth(int(table.width() + 20))
return self._group_box return self._group_box
@@ -2679,14 +2733,14 @@ class QResultsTableWidget():
table.setFixedHeight(400) table.setFixedHeight(400)
_vbox2.addWidget(table) _vbox2.addWidget(table)
_vbox2.setAlignment(Qt.AlignCenter|Qt.AlignTop) _vbox2.setAlignment(Qt.AlignmentFlag(Qt.AlignCenter|Qt.AlignTop))
_vbox2_widget.setLayout(_vbox2) _vbox2_widget.setLayout(_vbox2)
self._group_box.setLayout(_vbox2) self._group_box.setLayout(_vbox2)
self._group_box.setContentsMargins(20, 20, 20, 20) self._group_box.setContentsMargins(20, 20, 20, 20)
self._group_box.setAlignment(Qt.AlignTop) self._group_box.setAlignment(Qt.AlignTop)
self._group_box.setFixedWidth(table.width() + 20) self._group_box.setFixedWidth(int(table.width() + 20))
return self._group_box return self._group_box