Changeset 844


Ignore:
Timestamp:
Apr 29, 2012 10:00:41 AM (12 years ago)
Author:
jemian
Message:

ready for next step

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'''
     3PySide-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
     14import caqlabel
     15import tools
     16
     17CaQLabel     = caqlabel.CaQLabel
     18CaQSignalDef = tools.CaQSignalDef
     19enum         = tools.enum
  • moxy/trunk/src/moxy/qtlib/caqlabel.py

    r843 r844  
    1616'''
    1717
     18
     19__version__ = '0.1'
     20
     21
    1822import epics
    1923import sys              #@UnusedImport
    20 import PySide.QtGui
    21 import tools
     24from PySide import QtGui
    2225import pprint           #@UnusedImport
    2326
    24 class CaQLabel(PySide.QtGui.QLabel):
     27from tools import CaQSignalDef, enum
     28
     29class CaQLabel(QtGui.QLabel):
    2530    '''
    2631    Provide the value of an EPICS PV on a PySide.QtGui.QLabel
     
    3338        '''
    3439        self.text = ' '*4
    35         PySide.QtGui.QLabel.__init__(self, self.text)
     40        QtGui.QLabel.__init__(self, self.text)
    3641
    3742        # define the signals we'll use in the camonitor handler to update the GUI
    38         self.labelSignal = tools.CaQSignalDef()
     43        self.labelSignal = CaQSignalDef()
    3944        self.labelSignal.newBgColor.connect(self.SetBackgroundColor)
    4045        self.labelSignal.newText.connect(self.SetText)
    4146       
    42         self.states = tools.enum('DISCONNECTED', 'CONNECTED', 'ALARM')
     47        self.states = enum('DISCONNECTED', 'CONNECTED', 'ALARM')
    4348        self.clut = {   # clut: Color LookUp Table
    4449            self.states.DISCONNECTED:     "#ffffff",      # white
     
    132137
    133138
    134 class DemoView(PySide.QtGui.QWidget):
     139class DemoView(QtGui.QWidget):
    135140    '''
    136141    Show an EPICS PV connection.
     
    140145
    141146    def __init__(self, parent=None, pvname=''):
    142         PySide.QtGui.QWidget.__init__(self, parent)
     147        QtGui.QWidget.__init__(self, parent)
    143148        self.value  = CaQLabel()
    144149
    145         grid = PySide.QtGui.QGridLayout()
     150        grid = QtGui.QGridLayout()
    146151        grid.addWidget(self.value,   0,0)
    147152        self.setLayout(grid)
    148153
    149         self.sig = tools.CaQSignalDef()
     154        self.sig = CaQSignalDef()
    150155        self.sig.newBgColor.connect(self.SetBackgroundColor)
    151156        self.toggle = False
     
    177182
    178183if __name__ == '__main__':
    179     app = PySide.QtGui.QApplication(sys.argv)
     184    app = QtGui.QApplication(sys.argv)
    180185    _demo = DemoView(pvname='prj:datetime')
    181186    _demo.show()
  • moxy/trunk/src/moxy/qtlib/pv.py

    r843 r844  
    1818
    1919import sys
    20 import PySide.QtGui
    21 from CaQLabel import CaQLabel
    22 import tools
     20from PySide import QtGui
     21from caqlabel import CaQLabel
     22from tools import CaQSignalDef
    2323
    2424
    25 class DemoView(PySide.QtGui.QWidget):
     25class DemoView(QtGui.QWidget):
    2626    '''
    2727    Show an EPICS PV connection.
     
    3131
    3232    def __init__(self, parent=None, pvname=''):
    33         PySide.QtGui.QWidget.__init__(self, parent)
     33        QtGui.QWidget.__init__(self, parent)
    3434
    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)
    3737        self.pvname.returnPressed.connect(self.onPVNameReturn)
    38         value_label = PySide.QtGui.QLabel("PV Value:")
     38        value_label = QtGui.QLabel("PV Value:")
    3939        self.value  = CaQLabel() 
    4040       
    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")
    4343        self.status_text = ''
    4444       
    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")
    4747        self.content_text = ''
    4848
    49         self.sig_status = tools.CaQSignalDef()
     49        self.sig_status = CaQSignalDef()
    5050        self.sig_status.newText.connect(self.SetStatus)
    51         self.sig_content = tools.CaQSignalDef()
     51        self.sig_content = CaQSignalDef()
    5252        self.sig_content.newText.connect(self.SetContent)
    5353
    54         grid = PySide.QtGui.QGridLayout()
     54        grid = QtGui.QGridLayout()
    5555        grid.addWidget(name_label,    0, 0)
    5656        grid.addWidget(self.pvname,   0, 1)
     
    8888
    8989if __name__ == '__main__':
    90     app = PySide.QtGui.QApplication(sys.argv)
     90    app = QtGui.QApplication(sys.argv)
    9191    probe = DemoView(pvname='prj:datetime')
    9292    probe.show()
  • moxy/trunk/src/moxy/qtlib/tools.py

    r842 r844  
    2020
    2121
    22 import PySide
     22from PySide import QtCore
    2323
    2424
     
    3232
    3333
    34 class CaQSignalDef(PySide.QtCore.QObject):
     34class CaQSignalDef(QtCore.QObject):
    3535    '''
    3636    Define the signals used to communicate between the PyEpics
    3737    thread and the PySide (main Qt4 GUI) thread.
    3838    '''
     39    # see: http://www.pyside.org/docs/pyside/PySide/QtCore/Signal.html
    3940    # 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 and
    42     # receiver apart from the emitter.
    43     # Use events.  Look at other's code.
    4441   
    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()
    5045
    5146
Note: See TracChangeset for help on using the changeset viewer.