source: bcdaqwidgets/trunk/src/demos/pyside_probe.py @ 1402

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

fixes #50

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision URL
File size: 1.5 KB
Line 
1#!/usr/bin/env python
2
3########### SVN repository information ###################
4# $Date: 2013-07-05 22:25:23 +0000 (Fri, 05 Jul 2013) $
5# $Author: jemian $
6# $Revision: 1402 $
7# $URL: bcdaqwidgets/trunk/src/demos/pyside_probe.py $
8# $Id: pyside_probe.py 1402 2013-07-05 22:25:23Z jemian $
9########### SVN repository information ###################
10
11# from Matt Newville, CARS, University of Chicago
12
13import epics
14import os
15import sys
16from PySide.QtGui import QWidget, QLabel, QLineEdit, QGridLayout, QApplication
17
18sys.path.insert(0, os.path.abspath('..'))
19import bcdaqwidgets
20
21class PVProbe(QWidget):
22    ''' '''
23    def __init__(self, parent=None):
24        QWidget.__init__(self, parent)
25
26        name_label  = QLabel("PV Name:")
27        self.pvname = QLineEdit()
28        value_label = QLabel("PV Value:")
29        self.value  = QLabel(" "*4)
30
31        self.pvname.returnPressed.connect(self.onPVNameReturn)
32        self.pv = None
33
34        grid = QGridLayout()
35        grid.addWidget(name_label,   0, 0)
36        grid.addWidget(self.pvname,  0, 1)
37        grid.addWidget(value_label,  1, 0)
38        grid.addWidget(self.value,   1, 1)
39
40        self.setLayout(grid)
41        self.setWindowTitle("PySide PV Probe:")
42
43    def onPVNameReturn(self):
44        if self.pv is not None:
45            self.pv.remove_callback()
46            self.pv.ca_disconnect()
47        self.pv = epics.PV(self.pvname.text(), callback=self.onPVChange)
48
49    def onPVChange(self, pvname=None, char_value=None, **kws):
50        self.value.setText(char_value)
51
52if __name__ == '__main__':
53    app = QApplication(sys.argv)
54    probe = PVProbe()
55    probe.show()
56    sys.exit(app.exec_())
Note: See TracBrowser for help on using the repository browser.