Changeset 844
- Timestamp:
- Apr 29, 2012 10:00:41 AM (12 years ago)
- Location:
- moxy/trunk/src/moxy/qtlib
- Files:
-
- 3 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
moxy/trunk/src/moxy/qtlib/__init__.py
r835 r844 1 2 ''' 3 PySide-based EPICS-aware widgets for Python 4 ''' 5 6 ########### SVN repository information ################### 7 # $Date$ 8 # $Author$ 9 # $Revision$ 10 # $URL$ 11 # $Id$ 12 ########### SVN repository information ################### 13 14 import caqlabel 15 import tools 16 17 CaQLabel = caqlabel.CaQLabel 18 CaQSignalDef = tools.CaQSignalDef 19 enum = tools.enum -
moxy/trunk/src/moxy/qtlib/caqlabel.py
r843 r844 16 16 ''' 17 17 18 19 __version__ = '0.1' 20 21 18 22 import epics 19 23 import sys #@UnusedImport 20 import PySide.QtGui 21 import tools 24 from PySide import QtGui 22 25 import pprint #@UnusedImport 23 26 24 class CaQLabel(PySide.QtGui.QLabel): 27 from tools import CaQSignalDef, enum 28 29 class CaQLabel(QtGui.QLabel): 25 30 ''' 26 31 Provide the value of an EPICS PV on a PySide.QtGui.QLabel … … 33 38 ''' 34 39 self.text = ' '*4 35 PySide.QtGui.QLabel.__init__(self, self.text)40 QtGui.QLabel.__init__(self, self.text) 36 41 37 42 # define the signals we'll use in the camonitor handler to update the GUI 38 self.labelSignal = tools.CaQSignalDef()43 self.labelSignal = CaQSignalDef() 39 44 self.labelSignal.newBgColor.connect(self.SetBackgroundColor) 40 45 self.labelSignal.newText.connect(self.SetText) 41 46 42 self.states = tools.enum('DISCONNECTED', 'CONNECTED', 'ALARM')47 self.states = enum('DISCONNECTED', 'CONNECTED', 'ALARM') 43 48 self.clut = { # clut: Color LookUp Table 44 49 self.states.DISCONNECTED: "#ffffff", # white … … 132 137 133 138 134 class DemoView( PySide.QtGui.QWidget):139 class DemoView(QtGui.QWidget): 135 140 ''' 136 141 Show an EPICS PV connection. … … 140 145 141 146 def __init__(self, parent=None, pvname=''): 142 PySide.QtGui.QWidget.__init__(self, parent)147 QtGui.QWidget.__init__(self, parent) 143 148 self.value = CaQLabel() 144 149 145 grid = PySide.QtGui.QGridLayout()150 grid = QtGui.QGridLayout() 146 151 grid.addWidget(self.value, 0,0) 147 152 self.setLayout(grid) 148 153 149 self.sig = tools.CaQSignalDef()154 self.sig = CaQSignalDef() 150 155 self.sig.newBgColor.connect(self.SetBackgroundColor) 151 156 self.toggle = False … … 177 182 178 183 if __name__ == '__main__': 179 app = PySide.QtGui.QApplication(sys.argv)184 app = QtGui.QApplication(sys.argv) 180 185 _demo = DemoView(pvname='prj:datetime') 181 186 _demo.show() -
moxy/trunk/src/moxy/qtlib/pv.py
r843 r844 18 18 19 19 import sys 20 import PySide.QtGui21 from CaQLabel import CaQLabel22 import tools 20 from PySide import QtGui 21 from caqlabel import CaQLabel 22 from tools import CaQSignalDef 23 23 24 24 25 class DemoView( PySide.QtGui.QWidget):25 class DemoView(QtGui.QWidget): 26 26 ''' 27 27 Show an EPICS PV connection. … … 31 31 32 32 def __init__(self, parent=None, pvname=''): 33 PySide.QtGui.QWidget.__init__(self, parent)33 QtGui.QWidget.__init__(self, parent) 34 34 35 name_label = PySide.QtGui.QLabel("PV Name:")36 self.pvname = PySide.QtGui.QLineEdit(pvname)35 name_label = QtGui.QLabel("PV Name:") 36 self.pvname = QtGui.QLineEdit(pvname) 37 37 self.pvname.returnPressed.connect(self.onPVNameReturn) 38 value_label = PySide.QtGui.QLabel("PV Value:")38 value_label = QtGui.QLabel("PV Value:") 39 39 self.value = CaQLabel() 40 40 41 status_label = PySide.QtGui.QLabel("status:")42 self.status = PySide.QtGui.QLabel("just starting")41 status_label = QtGui.QLabel("status:") 42 self.status = QtGui.QLabel("just starting") 43 43 self.status_text = '' 44 44 45 content_label = PySide.QtGui.QLabel("content:")46 self.content = PySide.QtGui.QLabel("just starting")45 content_label = QtGui.QLabel("content:") 46 self.content = QtGui.QLabel("just starting") 47 47 self.content_text = '' 48 48 49 self.sig_status = tools.CaQSignalDef()49 self.sig_status = CaQSignalDef() 50 50 self.sig_status.newText.connect(self.SetStatus) 51 self.sig_content = tools.CaQSignalDef()51 self.sig_content = CaQSignalDef() 52 52 self.sig_content.newText.connect(self.SetContent) 53 53 54 grid = PySide.QtGui.QGridLayout()54 grid = QtGui.QGridLayout() 55 55 grid.addWidget(name_label, 0, 0) 56 56 grid.addWidget(self.pvname, 0, 1) … … 88 88 89 89 if __name__ == '__main__': 90 app = PySide.QtGui.QApplication(sys.argv)90 app = QtGui.QApplication(sys.argv) 91 91 probe = DemoView(pvname='prj:datetime') 92 92 probe.show() -
moxy/trunk/src/moxy/qtlib/tools.py
r842 r844 20 20 21 21 22 import PySide22 from PySide import QtCore 23 23 24 24 … … 32 32 33 33 34 class CaQSignalDef( PySide.QtCore.QObject):34 class CaQSignalDef(QtCore.QObject): 35 35 ''' 36 36 Define the signals used to communicate between the PyEpics 37 37 thread and the PySide (main Qt4 GUI) thread. 38 38 ''' 39 # see: http://www.pyside.org/docs/pyside/PySide/QtCore/Signal.html 39 40 # see: http://zetcode.com/gui/pysidetutorial/eventsandsignals/ 40 # TODO: there must be an easier way to do this!41 # Some way that does not cache the event data and42 # receiver apart from the emitter.43 # Use events. Look at other's code.44 41 45 newFgColor = PySide.QtCore.Signal() 46 newBgColor = PySide.QtCore.Signal() 47 newText = PySide.QtCore.Signal() 48 # TODO: Can we have the caller give the list of signals to create? 49 # Signal v SignalInstance: we want the latter 42 newFgColor = QtCore.Signal() 43 newBgColor = QtCore.Signal() 44 newText = QtCore.Signal() 50 45 51 46
Note: See TracChangeset
for help on using the changeset viewer.