-
Notifications
You must be signed in to change notification settings - Fork 0
/
TemplateWidget.py
115 lines (93 loc) · 4.02 KB
/
TemplateWidget.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file '/tmp/tmprZv_PC.ui'
#
# Created: Wed Jun 11 09:29:58 2014
# by: PyQt4 UI code generator 4.6.2
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui, Qt
import PyTango
from taurus.qt.qtgui.display import TaurusLabel, TaurusLed
from cosywidgets.input import OpenWidgetButton
from cosywidgets.input import CommandComboBox
class Ui_Form(object):
def setupUi(self, Form, element):
self.deviceProxy = element[0]
description = element[1]
Form.setObjectName("Form")
Form.resize(260, 104)
self.verticalLayout = QtGui.QVBoxLayout(Form)
self.verticalLayout.setSpacing(1)
self.verticalLayout.setMargin(5)
self.verticalLayout.setObjectName("verticalLayout")
########################
# HORIZONTAL 1
########################
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
# Element Name -> OpenWidgetButton (Cosywidgets)
self.ElementName = OpenWidgetButton(Form)
self.ElementName.setText(self.deviceProxy.split("/")[2] + " ")
self.horizontalLayout.addWidget(self.ElementName)
# LED for state
self.stateT = TaurusLed(Form)
self.stateT.setFixedSize(QtCore.QSize(20, 20))
self.stateT.setObjectName("stateT")
self.horizontalLayout.addWidget(self.stateT)
# Command combobox (Cosywidgets)
self.comboBox = CommandComboBox(Form)
self.comboBox.setObjectName("comboBox")
self.comboBox.setFixedHeight(20)
self.horizontalLayout.addWidget(self.comboBox)
self.comboBox.addItems(["Start", "Stop", "Init"])
self.verticalLayout.addLayout(self.horizontalLayout)
########################
# HORIZONTAL 2
########################
self.horizontalLayout_2 = QtGui.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
# DESIRED ATTRIBUTE ...
self.pressure = QtGui.QLabel(Form)
self.pressure.setObjectName("pressure")
self.horizontalLayout_2.addWidget(self.pressure)
self.pressureT = TaurusLabel(Form)
self.pressureT.setObjectName("pressureT")
self.pressureT.setFixedWidth(180)
self.horizontalLayout_2.addWidget(self.pressureT)
self.pressureU = QtGui.QLabel(Form)
self.pressureU.setText("mBar")
self.horizontalLayout_2.addWidget(self.pressureU)
self.verticalLayout.addLayout(self.horizontalLayout_2)
########################
# HORIZONTAL 3
########################
# ...
########################
# DESCRIPTION
########################
self.descLabel = QtGui.QLabel(u'\u2022' + " " + description)
self.descLabel.setStyleSheet("background-color: lightblue; border: 1px solid grey;")
self.descLabel.setToolTip(description)
self.verticalLayout.addSpacing(2)
self.verticalLayout.addWidget(self.descLabel)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtGui.QApplication.UnicodeUTF8))
self.pressure.setText(QtGui.QApplication.translate("Form", "Pressure:", None, QtGui.QApplication.UnicodeUTF8))
# SHOW/HIDE DESCRIPTION
def showDescription(self, show):
if show:
self.descLabel.show()
else:
self.descLabel.hide()
# SEPARATE SET MODEL -> background thread
def setModel(self):
self.ElementName.setModel(self.deviceProxy)
self.stateT.setModel(self.deviceProxy + "/State")
self.comboBox.setModel(self.deviceProxy)
self.pressureT.setModel(self.deviceProxy + "/pressure")
try:
self.pressureU.setText(PyTango.AttributeProxy(self.deviceProxy + "/pressure").get_config().unit)
except PyTango.DevFailed:
pass