Changeset 702 for moxy/trunk/src


Ignore:
Timestamp:
Dec 2, 2011 4:06:57 PM (14 years ago)
Author:
jemian
Message:

making some real progress with the Traits-based GUI

Location:
moxy/trunk/src/moxy
Files:
5 added
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified moxy/trunk/src/moxy/axes_set.py

    r701 r702  
    1515Enthought Python Distribution.
    1616
    17 Copyright (c) 2011, UChicago Argonne, LLC
     17Copyright (c) 2009 - 2011, UChicago Argonne, LLC
    1818'''
    1919
    2020
    21 from enthought.traits.api import HasTraits, String, Instance, List
    22 from enthought.traits.ui.api import View, UItem, HGroup
     21from enthought.traits.api import HasTraits, String, Instance, List, Button
     22from enthought.traits.ui.api import View, UItem, VGrid, Label, UReadonly
    2323from single_axis import SingleAxis
    2424
     
    3333    '''
    3434    name = String
     35    configButton = Button(Label=name)       # TODO: Label assignment does not work yet
    3536    axes = List( Instance( SingleAxis ) )
     37    stopButton = Button(Label='STOP')
     38   
     39    # TODO: need a view more like the prototype
     40    # complication is when a PV is not connected
     41    # which can probably be solved by some kind of Dependency Trait
     42    '''
     43    prototype
     44   
     45    ========  =========  =========  =========
     46    axis      x         y          ...
     47    ========  =========  =========  =========
     48    readback  x_RBV     y_RBV      ..._RBV
     49    target    x_VAL     y_VAL      ..._VAL
     50    ========  =========  =========  =========
     51   
     52    [___________ STOP button ___________]
     53    '''
    3654   
    3755    view = View(
    3856               UItem('name', springy=True),
    39                HGroup('axes', springy=True, style='custom'),
     57               UItem('configButton'),
     58               UItem('axes', springy=True, style='custom'),
     59               UItem('stopButton'),
     60               UItem('axes[0]', springy=True, style='custom'),
    4061           )
     62   
     63    def _configButton_fired(self):
     64        print 'configButton pressed'
     65        self.axes[0].edit_traits()
     66   
     67    def _stopButton_fired(self):
     68        print 'STOP pressed'
    4169
    4270
     
    4573    from connection import PvConnection
    4674    kw = { 'name' : 'test set of axes'}
    47     axes = []
     75    global_axes = []
    4876    basic_config = {'x': 'prj:m1', 'y': 'prj:m2',}  # two test motor records
    4977    for axis in sorted(basic_config):
     
    5381            full_pv = base_pv + "." + field.upper()
    5482            inner[ field.lower() ] = PvConnection( pvname = full_pv )
    55         axes.append( SingleAxis(**inner) )
    56     kw[ 'axes' ] = axes
     83        global_axes.append( SingleAxis(**inner) )
     84    kw[ 'axes' ] = global_axes
    5785   
    58     AxesSet(**kw).configure_traits()
     86    # build the test view on-the-fly, based on the number of defined axes
     87    vg_args = []
     88    qty = len(global_axes)
     89    grid = []
     90    grid.append( Label('motor') )
     91    for axis in global_axes:
     92        grid.append( Label(axis.name) )
     93    grid.append( Label('readback') )
     94    for i in range(qty):
     95        grid.append( UReadonly('a%d.rbv.pvname'%i) )
     96    grid.append( Label('target') )
     97    for i in range(qty):
     98        grid.append( UItem('a%d.val.pvname'%i) )
     99    gridkw = {'columns': qty+1}
     100    vg_args.append( VGrid(*grid, **gridkw) )
     101    vkw = {'resizable': True}
     102   
     103    traits_context = {}
     104    for i in range(qty):
     105        axis = global_axes[i]
     106        traits_context['a%d'%i] = axis
     107   
     108    #AxesSet(**kw).configure_traits()
     109    AxesSet(**kw).configure_traits(view=View(*vg_args, **vkw), context=traits_context)
  • TabularUnified moxy/trunk/src/moxy/connection.py

    r701 r702  
    1515Enthought Python Distribution.
    1616
    17 Copyright (c) 2011, UChicago Argonne, LLC
     17Copyright (c) 2009 - 2011, UChicago Argonne, LLC
    1818'''
    1919
  • TabularUnified moxy/trunk/src/moxy/moxy.py

    r701 r702  
    1414========================================
    1515
    16 Build the Graphical User Interface
    17 using the Traits library from the
    18 Enthought Python Distribution.
     16Built using the Traits library from the
     17Enthought Python Distribution.
    1918
    2019Copyright (c) 2011, UChicago Argonne, LLC
     
    3130    UndoAction, RedoAction, Separator, HelpAction
    3231from axes_set import AxesSet
     32from positions_set import PositionsSet
    3333
    3434__svnid__ = "$Id$"
     
    4141    def show_about(self, uinfo):
    4242        '''About this application'''
    43         print 'About ...', __svnid__
     43        import about
     44        about.About().edit_traits()
    4445
    4546
     
    5051    '''
    5152    axes_sets = Dict( String, Instance( AxesSet ))
    52     user_positions = Dict( String, List( String ) )
     53    user_positions = Dict( String, List( PositionsSet ) )
    5354
    5455    status_label = String('status:')
     
    118119    outer = {
    119120             'axes_sets' : axes_sets,
    120              'user_positions': {},
     121             'user_positions': {'nothing': [PositionsSet()]},
    121122             }
    122123
  • TabularUnified moxy/trunk/src/moxy/single_axis.py

    r701 r702  
    1515Enthought Python Distribution.
    1616
    17 Copyright (c) 2011, UChicago Argonne, LLC
     17Copyright (c) 2009 - 2011, UChicago Argonne, LLC
    1818'''
    1919
    2020
    21 from enthought.traits.api import HasTraits, String, Instance
     21from enthought.traits.api import HasTraits, String, Instance, Bool
     22from enthought.traits.ui.api import View, Item
    2223from connection import PvConnection
    2324
     
    3839    stop = Instance( PvConnection )
    3940    desc = Instance( PvConnection )
     41    isMotorRecord = Bool(True)
     42   
     43
     44config_view = View(
     45                   Item('axis.name'),
     46                   Item('axis.val.pvname'),
     47                   Item('axis.rbv.pvname'),
     48              )
    4049
    4150if __name__ == '__main__':
     
    4857   
    4958    SingleAxis(**kw).configure_traits()
     59   
     60    single = SingleAxis(**kw)
     61    single.configure_traits(view=config_view, context={'axis': single})
Note: See TracChangeset for help on using the changeset viewer.