source: bcdaqwidgets/trunk/src/bcdaqwidgets_demos/pvview.py @ 1443

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

figured out how to create and install starter scripts using setup.py

  • 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()
44        widget.ca_connect(pvname)
45        widget.useAlarmState = True
46        self.db[pvname] = widget
47        self.grid.addWidget(label, row, 0)
48        self.grid.addWidget(widget, row, 1)
49
50
51def main():
52    app = QApplication(sys.argv)
53    probe = PVView()
54    if len(sys.argv) < 2:
55        raise RuntimeError, "Must specify one or more EPICS PVs on command line"
56    for pvname in sys.argv[1:]:
57        probe.add(pvname)
58    probe.show()
59    sys.exit(app.exec_())
60
61
62if __name__ == '__main__':
63    main()
64
65
66########### SVN repository information ###################
67# $Date: 2013-10-16 01:22:10 +0000 (Wed, 16 Oct 2013) $
68# $Author: jemian $
69# $Revision: 1443 $
70# $URL: bcdaqwidgets/trunk/src/bcdaqwidgets_demos/pvview.py $
71# $Id: pvview.py 1443 2013-10-16 01:22:10Z jemian $
72########### SVN repository information ###################
Note: See TracBrowser for help on using the repository browser.