EPICS Home

Experimental Physics and Industrial Control System


 
1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: QT-based tools: Expressions of interest requested
From: Pete Jemian <[email protected]>
To: [email protected]
Date: Thu, 23 Feb 2012 18:41:10 -0600


Matt:

Attached is Probe, rendered in Python using Enthought's Traits and PyEpics. Traits can be configured for either QT4 or wx (default) as a backend.

Pete


--
----------------------------------------------------------
 Pete R. Jemian, Ph.D.                <[email protected]>
 Beam line Controls and Data Acquisition, Group Leader
 Advanced Photon Source,   Argonne National Laboratory
 Argonne, IL  60439                   630 - 252 - 3189
-----------------------------------------------------------
    Education is the one thing for which people
       are willing to pay yet not receive.
-----------------------------------------------------------

#!/usr/bin/env python

import epics
import sys

from enthought.etsconfig.api import ETSConfig
#ETSConfig.toolkit='qt4'

from traits.api import *    #@UnusedWildImport
from traitsui.api import *  #@UnusedWildImport

from traitsui.key_bindings \
    import KeyBinding, KeyBindings

key_bindings = KeyBindings(
    KeyBinding( binding1    = 'Enter',
                description = 'Connect to new PV',
                method_name = 'connect' ),
)

# TraitsUI Handler class for bound methods
class CodeHandler ( Handler ):

    def connect ( self, info ):
        if len(info.object.name) > 2:
            try:
                if info.object._chid is not None:
                    info.object._chid.clear_callbacks()
                    info.object._chid.disconnect()
            except:
                pass
            info.object._chid = epics.PV(str(info.object.name))
            info.object._chid.add_callback(info.object.std_callback)


class Probe( HasTraits ):
    name = Str
    value = Str
    _chid = Instance( epics.PV, value = None )

    def std_callback(self, value=None, **kwds):
        "simple monitor callback"
        self.value = str(value)

    traits_view = View(
        Item('name'),
        Readonly('value'),
        resizable=True,
        title='Traits-based EPICS Probe',
        key_bindings = key_bindings,
        handler   = CodeHandler()
    )

if __name__ == '__main__':
    name = ''
    if len(sys.argv) == 2:
        name = sys.argv[1]
    probe = Probe(name=name)
    probe.configure_traits()

References:
QT-based tools: Expressions of interest requested Andrew Johnson
RE: QT-based tools: Expressions of interest requested ian.gillingham
Re: QT-based tools: Expressions of interest requested Emmanuel Mayssat
Re: QT-based tools: Expressions of interest requested Matt Newville

Navigate by Date:
Prev: Re: Issues for pvAssing() in seq Benjamin Franksen
Next: RE: QT-based tools: Expressions of interest requested james.rowland
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: QT-based tools: Expressions of interest requested djquock
Next: Re: QT-based tools: Expressions of interest requested Emmanuel Mayssat
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024