Skip to content

Commit

Permalink
LINAC Screens: Fix Active Screen selection
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelLyra8 committed Nov 22, 2022
1 parent 4f3aaf0 commit 77c4ba8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion pyqt-apps/scripts/sirius-hla-li-rf-llrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
app = SiriusApplication()
window = create_window_from_widget(
LLRFMain, title='LI LLRF', is_main=True,
withscroll=True, min_width=105, min_height=55,
withscroll=True, min_width=90, min_height=45,
icon=_qta.icon(
'mdi.waves', color=_util.get_appropriate_color('LI')))
app.open_window(
Expand Down
47 changes: 24 additions & 23 deletions pyqt-apps/siriushla/li_di_scrns/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
from qtpy.QtCore import Qt
from qtpy.QtGui import QPixmap
from qtpy.QtWidgets import QGroupBox, QHBoxLayout, QVBoxLayout, \
QWidget, QLabel, QGridLayout, QRadioButton, QStackedWidget, \
QWidget, QLabel, QGridLayout, QStackedWidget, \
QSizePolicy
from pydm.widgets import PyDMPushButton, PyDMImageView, PyDMLineEdit
from pydm.widgets import PyDMPushButton, PyDMImageView, PyDMLineEdit, \
enum_button
import qtawesome as qta
from ..util import get_appropriate_color
from ..widgets import SiriusMainWindow, PyDMLedMultiChannel, \
SiriusWaveformPlot, SiriusLabel, SiriusSpinbox
SiriusWaveformPlot, SiriusLabel, SiriusSpinbox, SiriusConnectionSignal
from .util import DEVICES, SCREENS_PANEL, SCREENS_INFO, HEADER, \
GRAPH, SCREEN
from .motorBtn import MotorBtn
Expand Down Expand Up @@ -40,15 +41,13 @@ def __init__(self, prefix='', parent=None):
self.stack_graphs = QStackedWidget()
self._setupUi()

def radioBtnClick(self):
def radioBtnClick(self, value):
''' Action on radio button change '''
radio_button = self.sender()
if radio_button.isChecked():
self.selected_device = radio_button.device
device_index = DEVICES.index(self.selected_device)
self.stack_screens.setCurrentIndex(device_index)
self.stack_screen.setCurrentIndex(device_index)
self.stack_graphs.setCurrentIndex(device_index)
self.selected_device = DEVICES[value]
device_index = DEVICES.index(self.selected_device)
self.stack_screens.setCurrentIndex(device_index)
self.stack_screen.setCurrentIndex(device_index)
self.stack_graphs.setCurrentIndex(device_index)

def getPvName(self, device, pv_name):
''' Build PV name '''
Expand Down Expand Up @@ -87,14 +86,16 @@ def setWidgetType(self, wid_type, device, pv_name, label='', value=0):
widget.setFixedHeight(20)
return widget

def getRadioBtn(self, device):
''' Get the one radio button '''
radio_button = QRadioButton(device)
radio_button.device = device
radio_button.toggled.connect(self.radioBtnClick)
if device == DEVICES[0]:
radio_button.setChecked(True)
return radio_button
def selectionItem(self, channel):
'''Build a selection widget'''
selector = enum_button.PyDMEnumButton(
init_channel=self.prefix + self.device_name+":"+channel)
self.active_screen = SiriusConnectionSignal(
self.prefix + self.device_name+":"+channel)
self.active_screen.new_value_signal[int].connect(
self.radioBtnClick)
selector.widgetType = 1
return selector

def setBasicInfo(self, device, label, pv_name):
''' Build one basic information Component '''
Expand Down Expand Up @@ -206,10 +207,6 @@ def setPanelInfo(self, device, layout, row):
pv_name = 'MOTOR' + ":"
count = 0

layout.addWidget(
self.getRadioBtn(device),
row, count, alignment=Qt.AlignCenter)

count += 1
for item in range(0, len(pv_list)):
if item == 0:
Expand Down Expand Up @@ -246,6 +243,10 @@ def setScrnPanel(self):
am_glay = self.setScrnHeader(am_glay)

row = 1
am_glay.addWidget(
self.selectionItem('PRF:OPI'),
row, 0, 5, 1,
alignment=Qt.AlignCenter)
for device in DEVICES:
am_glay = self.setPanelInfo(
device, am_glay, row)
Expand Down

0 comments on commit 77c4ba8

Please sign in to comment.