source: bcdaqwidgets/trunk/src/bcdaqwidgets/pvview.py @ 1447

Last change on this file since 1447 was 1447, checked in by jemian, 9 years ago

change to use autoconnect feature

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Date Revision Author HeadURL Id
File size: 1.9 KB
Line 
1#!/usr/bin/env python
2
3'''display one or more EPICS PVs in a PySide GUI window as a table'''
4
5import os
6import sys
7from PySide.QtGui import QWidget, QLabel, QGridLayout, QApplication
8
9#sys.path.insert(0, os.path.abspath('..'))
10import bcdaqwidgets
11
12class PVView(QWidget):
13    ''' '''
14    def __init__(self, parent=None):
15        QWidget.__init__(self, parent)
16        self.db = {}
17
18        name_label  = QLabel("PV Name")
19        value_label = QLabel("PV Value")
20        for item in (name_label, value_label):
21            sty = bcdaqwidgets.StyleSheet(item, {
22                                   'background-color': 'gray',
23                                   'color': 'white',
24                                   'font': 'bold',
25                                   })
26            sty.updateStyleSheet()
27
28        self.grid = QGridLayout()
29        self.grid.addWidget(name_label,   0, 0)
30        self.grid.addWidget(value_label,  0, 1)
31        self.grid.setColumnStretch(0, 0)
32        self.grid.setColumnStretch(1, 1)
33
34        self.setLayout(self.grid)
35        self.setWindowTitle("EPICS PV View")
36
37    def add(self, pvname):
38        '''add a PV to the table'''
39        if pvname in self.db:
40            return
41        row = len(self.db) + 1
42        label = QLabel(pvname)
43        widget = bcdaqwidgets.BcdaQLabel(pvname=pvname)
44        widget.useAlarmState = True
45        self.db[pvname] = widget
46        self.grid.addWidget(label, row, 0)
47        self.grid.addWidget(widget, row, 1)
48
49
50def main():
51    app = QApplication(sys.argv)
52    probe = PVView()
53    if len(sys.argv) < 2:
54        raise RuntimeError, "Must specify one or more EPICS PVs on command line"
55    for pvname in sys.argv[1:]:
56        probe.add(pvname)
57    probe.show()
58    sys.exit(app.exec_())
59
60
61if __name__ == '__main__':
62    main()
63
64
65########### SVN repository information ###################
66# $Date: 2013-10-16 16:02:41 +0000 (Wed, 16 Oct 2013) $
67# $Author: jemian $
68# $Revision: 1447 $
69# $URL: bcdaqwidgets/trunk/src/bcdaqwidgets/pvview.py $
70# $Id: pvview.py 1447 2013-10-16 16:02:41Z jemian $
71########### SVN repository information ###################
Note: See TracBrowser for help on using the repository browser.