import taurus,PyQt4,panic
from taurus.qt.qtgui.panel import TaurusForm
qapp = PyQt4.Qt.QApplication([])
#Obtain all alarm attributes (get_attribute() returns just attr name, with full=True returns device/attr)
alarms = panic.api()
all_alarm_attributes = [a.get_attribute(full=True) for a in sorted(alarms.values())]
#Then create a taurusform and display the attributes
tf = TaurusForm()
tf.setWindowTitle('My Alarms')
tf.setWithButtons(False)
tf.addModels(all_alarm_attributes)
from taurus.qt.qtgui.display import TaurusBoolLed
for attr in sorted(all_alarm_attributes):
#Get the widget in the form linked to this alarm attribute
widget = tf.getItemByModel(attr)
#Replacing the default Led in forms by a TaurusBoolLed
widget.setReadWidgetClass(TaurusBoolLed)
#Assigning RED as ON/True color
widget.readWidget().setLedColor('RED')
tf.show()
qapp.exec_()
The code I pasted should display something like the attached screenshot.Tips and Tricks on Python, PyTango, Tango, MySQL, Taurus, Numpy , ...
if you're searching for official Tango documentation go to tango-controls.org
Thursday, 6 August 2015
Showing PANIC alarms in a TaurusForm
This recipe creates an instance of the PANIC (PyTango Alarm System) Api; then it uses the taurus library to display all active alarms in a Taurus-Form widget (see screenshot):
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment