Commit aebd8cb6 authored by Tiago Sarmento's avatar Tiago Sarmento

committing for merge

parent 310fc3de
......@@ -63,21 +63,21 @@ class NativeUI(HEVClient, QMainWindow):
super(NativeUI, self).__init__(*args, **kwargs)
self.setWindowTitle("HEV NativeUI")
#self.setFixedSize(1920, 1080)
self.modeList = ["PC_AC", "PC_AC_PRVC", "PC_PSV", "CPAP"]
# self.setFixedSize(1920, 1080)
self.modeList = ["PC/AC", "PC/AC-PRVC", "PC-PSV", "CPAP"]
self.currentMode = self.modeList[0]
PID_I_plot_scale = 3
self.colors = { # colorblind friendly ref: https://i.stack.imgur.com/zX6EV.png
"background": QColor.fromRgb(30, 30, 30),
"foreground": QColor.fromRgb(200, 200, 200),
"background-enabled": QColor.fromRgb(50, 50, 50),
"background-disabled": QColor.fromRgb(15, 15, 15),
"foreground-disabled": QColor.fromRgb(100, 100, 100),
"baby-blue": QColor.fromRgb(144, 231, 211),
"modified-text": QColor.fromRgb(200, 0, 0),
"green": QColor.fromRgb(0, 150, 0),
"red": QColor.fromRgb(200, 0, 0),
"pressure_plot": QColor.fromRgb(0, 114, 178),
"volume_plot": QColor.fromRgb(0, 158, 115),
"flow_plot": QColor.fromRgb(240, 228, 66),
......@@ -136,10 +136,6 @@ class NativeUI(HEVClient, QMainWindow):
"__personal",
]
# bars
self.topBar = TabTopBar(self)
self.leftBar = TabLeftBar(self)
# Views
self.stack = QStackedWidget(self)
self.main_view = MainView(self)
......@@ -151,6 +147,10 @@ class NativeUI(HEVClient, QMainWindow):
self.modes_view = ModeView(self)
self.stack.addWidget(self.modes_view)
# bars
self.topBar = TabTopBar(self)
self.leftBar = TabLeftBar(self)
self.confirmPopup = confirmPopup(
self, self
) # one is passed as an argument, the other becomes parent
......@@ -454,9 +454,9 @@ def set_window_size(window, windowed: bool = False) -> int:
If the "windowed" argument is True, the window will be bordered, and 30% smaller on
each side.
"""
window_size = [1920, 1080]
window_size = [1920, 900]
if windowed:
rescale = 0.7
rescale = 0.5
window.setGeometry(0, 0, rescale * window_size[0], rescale * window_size[1])
else:
window.setFixedSize(*window_size)
......
......@@ -16,12 +16,9 @@ from PySide2 import QtWidgets, QtGui, QtCore
from global_widgets.template_set_values import TemplateSetValues
class TabClinical(
TemplateSetValues
): # chose QWidget over QDialog family because easier to modify
class TabClinical(TemplateSetValues):
def __init__(self, *args, **kwargs):
super(TabClinical, self).__init__(*args, **kwargs)
self.liveUpdating = True
clinicalList = [
["APNEA", "ms", ""],
["Check Pressure Patient", "ms", ""],
......
......@@ -33,11 +33,10 @@ class signallingLineEdit(QtWidgets.QLineEdit):
class labelledLineEdit(QtWidgets.QWidget):
def __init__(self, template, NativeUI, infoArray, *args, **kwargs):
def __init__(self, NativeUI, infoArray, *args, **kwargs):
super(labelledLineEdit, self).__init__(*args, **kwargs)
# print(infoArray)
self.NativeUI = NativeUI
self.template = template
self.cmd_type, self.cmd_code = "", ""
self.min, self.max, self.step = 0, 10000, 0.3
self.decPlaces = 2
......@@ -92,7 +91,7 @@ class labelledLineEdit(QtWidgets.QWidget):
self.setLayout(layout)
def update_personal_value(self):
newVal = self.NativeUI.get_db('personal')
newVal = self.NativeUI.get_db("personal")
if newVal == {}:
a = 1 # do nothing
else:
......
......@@ -31,17 +31,29 @@ class okButton(
self.setIcon(QtGui.QIcon(pixmap))
self.setStyleSheet(
"background-color: " + NativeUI.colors["foreground"].name() + ";"
"color: " + NativeUI.colors["background"].name() + ";"
"QPushButton[bgColour='0']{background-color: "
+ NativeUI.colors["foreground"].name()
+ ";}"
"QPushButton[bgColour='1']{background-color: "
+ NativeUI.colors["green"].name()
+ ";}"
"QPushButton{color: " + NativeUI.colors["background"].name() + ";"
"border-color: " + NativeUI.colors["foreground"].name() + ";"
"font-size: " + NativeUI.text_size + ";"
"border-radius: 8px;"
"border:none"
"border:none}"
)
self.setProperty("bgColour", "0")
self.setEnabled(False)
self.setFixedHeight(50)
# self.setFixedSize(QtCore.QSize(150, 50))
def setColour(self, option):
self.setEnabled(bool(float(option)))
self.setProperty("bgColour", str(option))
self.style().polish(self)
class cancelButton(
QtWidgets.QPushButton
......@@ -58,13 +70,64 @@ class cancelButton(
self.setIcon(QtGui.QIcon(pixmap))
self.setStyleSheet(
"background-color: " + NativeUI.colors["foreground"].name() + ";"
"color: " + NativeUI.colors["background"].name() + ";"
"QPushButton[bgColour='0']{background-color: "
+ NativeUI.colors["foreground"].name()
+ ";}"
"QPushButton[bgColour='1']{background-color: "
+ NativeUI.colors["red"].name()
+ ";}"
"QPushButton{color: " + NativeUI.colors["background"].name() + ";"
"border-color: " + NativeUI.colors["foreground"].name() + ";"
"font-size: " + NativeUI.text_size + ";"
"border-radius: 8px;"
"border:none}"
)
self.setProperty("bgColour", "0")
self.setEnabled(False)
self.setFixedHeight(50)
# self.setFixedSize(QtCore.QSize(150, 50))
def setColour(self, option):
self.setEnabled(bool(float(option)))
self.setProperty("bgColour", str(option))
self.style().polish(self)
class okSendButton(
QtWidgets.QPushButton
): # chose QWidget over QDialog family because easier to modify
def __init__(self, NativeUI, *args, **kwargs):
super().__init__(*args, **kwargs)
iconpath_play = os.path.join(NativeUI.iconpath, "play-solid.png")
# set icon color
pixmap = QtGui.QPixmap(iconpath_play)
mask = pixmap.mask()
pixmap.fill(NativeUI.colors["background"])
pixmap.setMask(mask)
self.setIcon(QtGui.QIcon(pixmap))
self.setStyleSheet(
"QPushButton[bgColour='0']{background-color: "
+ NativeUI.colors["foreground"].name()
+ ";}"
"QPushButton[bgColour='1']{background-color: "
+ NativeUI.colors["green"].name()
+ ";}"
"QPushButton{color: " + NativeUI.colors["background"].name() + ";"
"border-color: " + NativeUI.colors["foreground"].name() + ";"
"font-size: " + NativeUI.text_size + ";"
"border-radius: 8px;"
"border:none"
"border:none}"
)
self.setProperty("bgColour", "0")
self.setEnabled(False)
self.setFixedHeight(50)
# self.setFixedSize(QtCore.QSize(150, 50))
def setColour(self, option):
self.setEnabled(bool(float(option)))
self.setProperty("bgColour", str(option))
self.style().polish(self)
......@@ -68,7 +68,6 @@ class SetConfirmPopup(
self.setWindowOpacity(0.5)
def ok_button_pressed(self):
self.parentTemplate.liveUpdating = True
for command in self.commandList:
self.NativeUI.q_send_cmd(*command)
self.close()
......
......@@ -14,6 +14,7 @@ __status__ = "Prototype"
from PySide2 import QtWidgets, QtGui, QtCore
from global_widgets.global_typeval_popup import TypeValuePopup
from CommsCommon import ReadbackFormat
class signallingSpinBox(QtWidgets.QDoubleSpinBox):
......@@ -76,11 +77,13 @@ class labelledSpin(QtWidgets.QWidget):
It is created by an information array which indicates labels, units, command type and code for value setting,
and the range of permitted values"""
def __init__(self, template, NativeUI, infoArray, *args, **kwargs):
def __init__(self, NativeUI, infoArray, *args, **kwargs):
super(labelledSpin, self).__init__(*args, **kwargs)
# print(infoArray)
# a = ReadbackFormat()
# print(a)
self.NativeUI = NativeUI
self.template = template
self.cmd_type, self.cmd_code = "", ""
self.min, self.max, self.step = 0, 10000, 0.3
self.decPlaces = 2
......@@ -94,15 +97,13 @@ class labelledSpin(QtWidgets.QWidget):
self.label, self.units, self.tag = infoArray
self.manuallyUpdated = False
layout = QtWidgets.QHBoxLayout()
widgetList = []
self.layout = QtWidgets.QHBoxLayout()
textStyle = "color:white;" "font-size: " + NativeUI.text_size + ";"
if self.label != "":
self.nameLabel = QtWidgets.QLabel(self.label)
self.nameLabel.setStyleSheet(textStyle)
self.nameLabel.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
widgetList.append(self.nameLabel)
# if self.label != "":
self.nameLabel = QtWidgets.QLabel(self.label)
self.nameLabel.setStyleSheet(textStyle)
self.nameLabel.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.simpleSpin = signallingSpinBox(NativeUI)
self.simpleSpin.setRange(self.min, self.max)
......@@ -112,10 +113,14 @@ class labelledSpin(QtWidgets.QWidget):
"QDoubleSpinBox{ width:100px; font:16pt}"
"QDoubleSpinBox[bgColour='0']{background-color:"
+ NativeUI.colors["foreground"].name()
+ "; }"
+ "; color:"
+ NativeUI.colors["red"].name()
+ " }"
"QDoubleSpinBox[bgColour='1']{background-color:"
+ NativeUI.colors["background"].name()
+ ";}"
+ "; color:"
+ NativeUI.colors["foreground"].name()
+ " }"
"QDoubleSpinBox[textColour='0']{color:"
+ NativeUI.colors["background"].name()
+ "}"
......@@ -141,17 +146,15 @@ class labelledSpin(QtWidgets.QWidget):
self.simpleSpin.setEditability(False)
self.simpleSpin.style().polish(self.simpleSpin)
widgetList.append(self.simpleSpin)
self.unitLabel = QtWidgets.QLabel(self.units)
self.unitLabel.setStyleSheet(textStyle)
self.unitLabel.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
widgetList.append(self.unitLabel)
for widget in widgetList:
layout.addWidget(widget)
self.widgetList = [self.nameLabel, self.simpleSpin, self.unitLabel]
for widget in self.widgetList:
self.layout.addWidget(widget)
self.setLayout(layout)
self.setLayout(self.layout)
self.simpleSpin.manualChanged.connect(self.manualStep)
# self.simpleSpin.valueChanged.connect(self.valChange)
......@@ -159,7 +162,6 @@ class labelledSpin(QtWidgets.QWidget):
"""Handle changes in value. Change colour if different to set value, set updating values."""
if self.manuallyUpdated != True:
self.oldValue = self.simpleSpin.prevValue
self.template.liveUpdating = False
self.manuallyUpdated = True
if self.simpleSpin.value() != self.oldValue:
self.simpleSpin.setProperty("textColour", "1")
......@@ -170,7 +172,7 @@ class labelledSpin(QtWidgets.QWidget):
def update_readback_value(self):
newVal = self.NativeUI.get_db("readback")
if newVal == {}:
if newVal == {} or self.manuallyUpdated:
a = 1 # do nothing
else:
self.simpleSpin.setValue(newVal[self.tag])
......@@ -179,7 +181,7 @@ class labelledSpin(QtWidgets.QWidget):
def update_targets_value(self):
newVal = self.NativeUI.get_db("targets")
if (newVal == {}) or (self.tag == ""):
if (newVal == {}) or (self.tag == "") or self.manuallyUpdated:
a = 1 # do nothing
else:
self.simpleSpin.setValue(newVal[self.tag])
......@@ -187,10 +189,20 @@ class labelledSpin(QtWidgets.QWidget):
self.simpleSpin.style().polish(self.simpleSpin)
def update_personal_value(self):
newVal = self.NativeUI.get_db('personal')
newVal = self.NativeUI.get_db("personal")
if (newVal == {}) or (self.tag == ""):
a = 1 # do nothing
else:
self.simpleSpin.setValue(newVal[self.tag])
self.simpleSpin.setProperty("textColour", "0")
self.simpleSpin.style().polish(self.simpleSpin)
def insertWidget(self, widget, position):
self.insertedWidget = widget
self.widgetList.insert(position, widget)
for i in reversed(range(self.layout.count())):
self.layout.itemAt(i).widget().setParent(None)
# newLayout = QtWidgets.QHBoxLayout()
for widget in self.widgetList:
self.layout.addWidget(widget)
self.setLayout(self.layout)
......@@ -29,7 +29,7 @@ class TabModeswitchButton(QtWidgets.QWidget):
layout.addWidget(self.switchButton)
self.setLayout(layout)
self.mode_popup = False
self.mode_popup = modeswitchPopup(self.NativeUI)
self.switchButton.pressed.connect(self.switch_button_pressed)
def switch_button_pressed(self):
......@@ -44,22 +44,35 @@ class TabModeswitchButton(QtWidgets.QWidget):
self.switchButton.setText(self.mode_popup.mode)
class modeswitchPopup(QtWidgets.QDialog):
class modeswitchPopup(QtWidgets.QWidget):
def __init__(self, NativeUI, *args, **kwargs):
super(modeswitchPopup, self).__init__(*args, **kwargs)
self.NativeUI = NativeUI
self.settingsList = self.NativeUI.modes_view.modeTab.settingsList
self.settingsList = [
"Respiratory Rate",
"Inhale Time",
"IE Ratio",
"Inhale Trigger Sensitivity",
"Exhale Trigger Sensitivity",
"Inhale Pressure",
"Inhale Volume",
"Percentage O2",
] # self.NativeUI.modes_view.modeTab.settingsList
modeList = self.NativeUI.modeList
self.spinDict = self.NativeUI.modes_view.modeTab.spinDict
vradioLayout = QtWidgets.QVBoxLayout()
groupBox = QtWidgets.QGroupBox()
self.radioButtons = {}
for mode in modeList:
button = QtWidgets.QRadioButton(mode)
goToButton = QtWidgets.QPushButton(mode)
goToButton.pressed.connect(lambda j=mode: self.goToPressed(j))
hlayout = QtWidgets.QHBoxLayout()
hlayout.addWidget(button)
hlayout.addWidget(goToButton)
self.radioButtons[mode] = button
vradioLayout.addWidget(button)
vradioLayout.addLayout(hlayout)
button.pressed.connect(lambda i=button: self.update_settings_data(i))
groupBox.setLayout(vradioLayout)
......@@ -84,7 +97,7 @@ class modeswitchPopup(QtWidgets.QDialog):
vlayout2.addWidget(initVal)
vlayout3.addWidget(newVal)
for settings in self.settingsList:
namelabel = QtWidgets.QLabel(settings[0])
namelabel = QtWidgets.QLabel(settings)
namelabel.setAlignment(QtCore.Qt.AlignRight)
vlayout1.addWidget(namelabel)
......@@ -111,8 +124,10 @@ class modeswitchPopup(QtWidgets.QDialog):
hbuttonlayout = QtWidgets.QHBoxLayout()
self.okbutton = okButton(NativeUI)
self.okbutton.setEnabled(True)
self.okbutton.pressed.connect(self.ok_button_pressed)
self.cancelbutton = cancelButton(NativeUI)
self.cancelbutton.setEnabled(True)
self.cancelbutton.pressed.connect(self.cancel_button_pressed)
hbuttonlayout.addWidget(self.okbutton)
hbuttonlayout.addWidget(self.cancelbutton)
......@@ -125,7 +140,7 @@ class modeswitchPopup(QtWidgets.QDialog):
self.setLayout(vlayout)
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
radioButtons[0].click() # 1st button clicked by default
# self.radioButtons[self.NativeUI.currentMode].click() # 1st button clicked by default
# self.update_settings_data(radioButtons[0])
self.setStyleSheet(
......@@ -133,26 +148,39 @@ class modeswitchPopup(QtWidgets.QDialog):
"color:" + NativeUI.colors["foreground"].name() + ";"
"font: 16pt bold;"
)
self.radioButtons[self.NativeUI.currentMode].click()
#self.update_settings_data(self.radioButtons[0]) # should update according to the mode we're in
def goToPressed(self, mode):
self.NativeUI.stack.setCurrentWidget(self.NativeUI.modes_view)
self.NativeUI.modes_view.modeButton.click()
for button in self.NativeUI.modes_view.modeTab.buttonWidgets:
print(button.text())
print(mode)
if mode in button.text():
print("match!")
print(mode)
button.click()
self.close()
def update_settings_data(self, button):
self.mode = button.text()
self.spinDict = self.NativeUI.modes_view.modeTab.spinDict
self.mode = button.text().replace("/", "_").replace("-", "_")
data = self.NativeUI.get_db("targets")
for label, settings in zip(self.labelList, self.settingsList):
currentVal = data[settings[2]]
setVal = self.spinDict[self.mode + settings[0]].simpleSpin.value()
label.update_values(currentVal, setVal)
for settings, currentLabel, newLabel in zip(
self.settingsList, self.currentLabelList, self.newLabelList
):
currentVal = self.spinDict[
self.NativeUI.currentMode.replace("/", "_").replace("-", "_")
][settings].simpleSpin.value()
currentLabel.setText(str(round(currentVal, 4)))
setVal = self.spinDict[self.mode][settings].simpleSpin.value()
newLabel.setText(str(round(setVal, 4)))
def ok_button_pressed(self):
self.NativeUI.q_send_cmd("SET_MODE", self.mode)
self.NativeUI.currentMode = self.mode
# need to decide whetehr this sets individual values or just mode
# for label,settings in zip(self.labelList,self.settingsList):
# currentVal = data[settings[2]]
# setVal = self.spinDict[self.mode + settings[0]].simpleSpin.value()
# label.update_values(currentVal, setVal)
self.close()
def cancel_button_pressed(self):
......
......@@ -26,7 +26,6 @@ class SpinButton(QtWidgets.QFrame):
def __init__(self, NativeUI, label, code):
super().__init__()
self.NativeUI = NativeUI
self.liveUpdating = True
self.manuallyUpdated = False
# self.setStyleSheet("background-color:blue;")
self.code = code
......@@ -38,7 +37,7 @@ class SpinButton(QtWidgets.QFrame):
# create and style label
self.label = QtWidgets.QLabel(label)
#self.label.setText("test label")
# self.label.setText("test label")
labelBgColour = "rgb(60,58,60)"
self.label.setStyleSheet(
......@@ -93,16 +92,13 @@ class SpinButton(QtWidgets.QFrame):
self.setStyleSheet("border:2px solid white; border-radius:4px; padding:0px; ")
def manualChanged(self):
print('manui')
self.liveUpdating = False
self.manuallyUpdated = True
self.setTextColour('2')
self.setTextColour("2")
def setTextColour(self, option):
self.simpleSpin.setProperty("colour", option)
self.simpleSpin.style().unpolish(self.simpleSpin)
self.simpleSpin.style().polish(self.simpleSpin)
def update_targets_value(self):
newVal = self.NativeUI.get_db("targets")
......@@ -120,16 +116,9 @@ class TabSpinButtons(QtWidgets.QWidget):
super(TabSpinButtons, self).__init__(*args, **kwargs)
self.NativeUI = NativeUI
# self.setStyleSheet("background-color:blue;")
self.liveUpdating = True
self.layout = QtWidgets.QHBoxLayout()
self.layout.setSpacing(5)
# self.spinInsp = SpinButton(NativeUI)
# self.spinRR = SpinButton(NativeUI)
# self.spinFIo2 = SpinButton(NativeUI)
# self.spinInhaleT = SpinButton(NativeUI)
#self.__spins = [self.spinInsp, self.spinRR, self.spinFIo2, self.spinInhaleT]
self.__labels = ["P_insp [cm H2O]", "RR", "FIO2 [%]", "Inhale Time [s]"]
self.__codes = [
"inspiratory_pressure",
......@@ -137,10 +126,11 @@ class TabSpinButtons(QtWidgets.QWidget):
"fiO2_percent",
"inhale_time",
]
#self.cmd_code = [code.upper() for code in self.__codes]
self.spinDict = {}
for label,code in zip(self.__labels, self.__codes):
for label, code in zip(self.__labels, self.__codes):
self.spinDict[code] = SpinButton(NativeUI, label, code)
self.spinDict[code].simpleSpin.manualChanged.connect(self.colourButtons)
self.layout.addWidget(self.spinDict[code])
self.buttonLayout = QtWidgets.QVBoxLayout()
......@@ -160,51 +150,43 @@ class TabSpinButtons(QtWidgets.QWidget):
self.timer = QtCore.QTimer()
self.timer.setInterval(160)
self.timer.timeout.connect(self.updatetargets)
self.timer.timeout.connect(self.update_targets)
self.timer.start()
def updatetargets(self):
def colourButtons(self):
self.okButton.setColour(1)
self.cancelButton.setColour(1)
def update_targets(self):
for widget in self.spinDict:
self.spinDict[widget].update_targets_value() # pass database
# targets = self.NativeUI.get_db("targets")
# if targets == {}:
# return
# if targets["mode"] == "CURRENT":
# for spin, code in zip(self.__spins, self.__codes):
# if spin.simpleSpin.value() != float(targets[code]):
# if spin.liveUpdating:
# spin.simpleSpin.setValue(float(targets[code]))
# spin.setTextColour("2")
# else:
# spin.setTextColour("0")
# else:
# spin.setTextColour("2")
self.spinDict[widget].update_targets_value() # pass database
def ok_button_pressed(self):
message, command = [], []
for widget in self.spinDict:
if self.spinDict[widget].manuallyUpdated:
setVal = self.spinDict[widget].simpleSpin.value()
message.append("set" + self.spinDict[widget].label.text() + " to " + str(setVal))
message.append(
"set" + self.spinDict[widget].label.text() + " to " + str(setVal)
)
command.append(
[
'SET_TARGET_PC_AC',
self.spinDict[widget].code.upper(),
setVal,
]
["SET_TARGET_PC_AC", self.spinDict[widget].code.upper(), setVal]
)
self.popup = SetConfirmPopup(self, self.NativeUI, message, command)
self.popup.okButton.pressed.connect(self.commandSent)
self.popup.show()
def commandSent(self):
self.okButton.setColour(0)
self.cancelButton.setColour(0)
for widget in self.spinDict:
if self.spinDict[widget].manuallyUpdated:
self.spinDict[widget].manuallyUpdated = False
self.spinDict[spin].setTextColour("1")
self.spinDict[widget].setTextColour("1")
def cancel_button_pressed(self):
self.okButton.setColour(0)
self.cancelButton.setColour(0)
for spin in self.spinDict:
self.spinDict[spin].liveUpdating = True
self.spinDict[spin].manuallyUpdated = False
self.spinDict[spin].setTextColour("1")
#!/usr/bin/env python3
"""
tab_modes.py
"""
__author__ = ["Benjamin Mummery", "Tiago Sarmento"]
__credits__ = ["Benjamin Mummery", "Dónal Murray", "Tim Powell", "Tiago Sarmento"]
__license__ = "GPL"
__version__ = "0.0.1"
__maintainer__ = "Tiago Sarmento"
__email__ = "tiago.sarmento@stfc.ac.uk"
__status__ = "Development"
from PySide2 import QtWidgets, QtGui, QtCore
from global_widgets.global_select_button import selectorButton
# from global_widgets.global_spinbox import simpleSpin
# from global_widgets.global_spinbox import signallingSpinBox
from global_widgets.template_main_pages import TemplateMainPages
from global_widgets.template_set_values import TemplateSetValues
class TabModes(TemplateSetValues):
class TabModes(
TemplateMainPages
): # chose QWidget over QDialog family because easier to modify
def __init__(self, NativeUI, *args, **kwargs):
super(TabModes, self).__init__(NativeUI, *args, **kwargs)
self.NativeUI = NativeUI
self.settingsList = [
[
"Respiratory Rate",
......@@ -53,19 +43,150 @@ class TabModes(TemplateSetValues):
"SET_TARGET_",
"INSPIRATORY_PRESSURE",
],
["Inhale volume", "", "volume", "SET_TARGET_", "VOLUME"],
["Inhale Volume", "", "volume", "SET_TARGET_", "VOLUME"],
["Percentage O2", "", "fiO2_percent", "SET_TARGET_", "FIO2_PERCENT"],
]
self.addModeStack(self.settingsList)
self.addButtons()
self.finaliseLayout()
hlayout = QtWidgets.QHBoxLayout()
hlayout.setSpacing(0)
self.pcacButton = selectorButton(NativeUI, "PC/AC")
self.pcacButton.setProperty("selected", "1")
self.pcacButton.style().polish(self.pcacButton)
self.pcacEnable = [1, 0, 1, 1, 0, 1, 0, 1]
self.pcacVals = [1, 2, 3, 4, 5, 6, 7, 8]
self.pcacPage = TemplateSetValues(NativeUI)
self.prvcButton = selectorButton(NativeUI, "PC/AC-PRVC")
self.prvcEnable = [1, 1, 0, 1, 0, 1, 1, 1]
self.prvcVals = [2, 3, 4, 5, 6, 7, 8, 9]
self.prvcPage = TemplateSetValues(NativeUI)
self.psvButton = selectorButton(NativeUI, "PC-PSV")
self.psvEnable = [1, 1, 0, 1, 0, 1, 0, 1]
self.psvVals = [3, 4, 5, 6, 7, 8, 9, 1]
self.psvPage = TemplateSetValues(NativeUI)
self.cpapButton = selectorButton(NativeUI, "CPAP")
self.cpapEnable = [1, 0, 1, 1, 0, 1, 0, 1]
self.cpapVals = [4, 5, 6, 7, 8, 9, 1, 2]
self.cpapPage = TemplateSetValues(NativeUI)
self.buttonWidgets = [
self.pcacButton,
self.prvcButton,
self.psvButton,
self.cpapButton,
]
enableList = [self.pcacEnable, self.prvcEnable, self.psvEnable, self.cpapEnable]
self.tabsList = [self.pcacPage, self.prvcPage, self.psvPage, self.cpapPage]
self.valsList = [self.pcacVals, self.prvcVals, self.psvVals, self.cpapVals]
self.modeList = self.NativeUI.modeList
self.spinDict = {}
for tab, mode, enable, vals in zip(
self.tabsList, self.modeList, enableList, self.valsList
):
mode = mode.replace("/", "_")
mode = mode.replace("-", "_")
tempSettingsList = [
[
target.replace("SET_TARGET_", "SET_TARGET_" + mode)
for target in spinInfo
]
for spinInfo in self.settingsList
]
tab.addSpinSingleCol(tempSettingsList)
tab.mode = mode
tab.buttonGroup = QtWidgets.QButtonGroup()
for labelledSpin in tab.spinDict:
if tab.spinDict[labelledSpin].label == "Inhale Time":
tab.radioButtonTime = QtWidgets.QRadioButton()
tab.radioButtonTime.toggled.connect(
lambda i=tab.radioButtonTime, j=tab.spinDict[
labelledSpin
]: self.radioPressed(i, j)
)
tab.spinDict[labelledSpin].insertWidget(tab.radioButtonTime, 1)
tab.buttonGroup.addButton(tab.radioButtonTime)
tab.radioButtonTime.setChecked(bool(enable[1]))
if tab.spinDict[labelledSpin].label == "IE Ratio":
tab.radioButtonRat = QtWidgets.QRadioButton()
tab.radioButtonRat.toggled.connect(
lambda i=tab.radioButtonRat, j=tab.spinDict[
labelledSpin
]: self.radioPressed(i, j)
)
tab.spinDict[labelledSpin].insertWidget(tab.radioButtonRat, 1)
tab.buttonGroup.addButton(tab.radioButtonRat)
tab.radioButtonRat.setChecked(bool(enable[2]))
tab.addModeButtons()
tab.finaliseLayout()
self._setEnabled(tab, enable, vals)
self.spinDict[mode] = tab.spinDict
# self.addRadioButtons()
self.buildPage(self.buttonWidgets, self.tabsList)
def addRadioButtons(self):
for tab in self.tabsList:
tab.buttonGroup = QtWidgets.QButtonGroup()
for labelledSpin in tab.spinDict:
if tab.spinDict[labelledSpin].label == "Inhale Time":
tab.radioButtonTime = QtWidgets.QRadioButton()
tab.radioButtonTime.toggled.connect(
lambda i=tab.radioButtonTime, j=tab.spinDict[
labelledSpin
]: self.radioPressed(i, j)
)
tab.spinDict[labelledSpin].insertWidget(tab.radioButtonTime, 1)
tab.buttonGroup.addButton(tab.radioButtonTime)
if tab.spinDict[labelledSpin].label == "IE Ratio":
tab.radioButtonRat = QtWidgets.QRadioButton()
tab.radioButtonRat.toggled.connect(
lambda i=tab.radioButtonRat, j=tab.spinDict[
labelledSpin
]: self.radioPressed(i, j)
)
tab.spinDict[labelledSpin].insertWidget(tab.radioButtonRat, 1)
tab.buttonGroup.addButton(tab.radioButtonRat)
def radioPressed(self, radioButtonState, labelledSpin):
labelledSpin.simpleSpin.setEnabled(radioButtonState)
labelledSpin.simpleSpin.setProperty("bgColour", str(int(not radioButtonState)))
labelledSpin.simpleSpin.setProperty(
"textColour", str(int(not radioButtonState))
)
labelledSpin.simpleSpin.style().unpolish(labelledSpin.simpleSpin)
labelledSpin.simpleSpin.style().polish(labelledSpin.simpleSpin)
def _setColour(self, buttonWidg):
for button, page in zip(self.buttonWidgets, self.pageList):
for button, box in zip(self.buttonWidgets, self.pageList):
if button == buttonWidg:
button.setProperty("selected", "1")
self.stack.setCurrentWidget(page)
self.stack.setCurrentWidget(box)
else:
button.setProperty("selected", "0")
button.style().unpolish(button)
button.style().polish(button)
def _modeSwitch(self, box):
self.stack.setCurrentWidget(box)
def _setEnabled(self, box, enableList, values):
for widget, enableBool, value in zip(box.spinDict, enableList, values):
box.spinDict[widget].simpleSpin.setEnabled(enableBool)
if enableBool == 1:
box.spinDict[widget].simpleSpin.setProperty("bgColour", "0")
box.spinDict[widget].simpleSpin.setProperty("textColour", "0")
if enableBool == 0:
box.spinDict[widget].simpleSpin.setProperty("bgColour", "1")
box.spinDict[widget].simpleSpin.setProperty("textColour", "1")
box.spinDict[widget].simpleSpin.style().unpolish(
box.spinDict[widget].simpleSpin
)
box.spinDict[widget].simpleSpin.style().polish(
box.spinDict[widget].simpleSpin
)
box.spinDict[widget].simpleSpin.setValue(value)
......@@ -23,7 +23,6 @@ from global_widgets.template_set_values import TemplateSetValues
class TabExpert(TemplateSetValues):
def __init__(self, NativeUI, *args, **kwargs):
super(TabExpert, self).__init__(NativeUI, *args, **kwargs)
self.liveUpdating = True
self.setPacketType("readback")
controlDict = {
......@@ -91,8 +90,3 @@ class TabExpert(TemplateSetValues):
self.addExpertControls(controlDict)
self.addButtons()
self.finaliseLayout()
# def update_settings_data(self):
# if self.liveUpdating:
# for widget in self.spinDict:
# self.spinDict[widget].update_readback_value()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment