File: widget_tutorial.rst

package info (click to toggle)
taurus 3.0.0-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 87,664 kB
  • sloc: python: 56,016; sh: 16; makefile: 14
file content (197 lines) | stat: -rw-r--r-- 5,877 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197

.. currentmodule:: taurus.qt.qtgui

.. _taurus-widget-tutorial:

======================
taurus widget tutorial
======================



.. todo::
    Update this page to Taurus. In the meanwhile, you can check the :ref:`examples`

..
    **UNDER CONSTRUCTION: OUT OF DATE**
    
    The widget package is a PyQt_ based library of widgets designed to represent 
    Tango_ data.
    The widget library provides not only basic widgets like labels, text fields and
    combo boxes, but also containers like frames, group boxes or graphics and 
    synoptics.
    
    .. _TaurusLabel-tutorial:
    
    TaurusLabel tutorial
    ----------------------
    
    The :class:`TaurusLabel` is a taurus widget designed to display the read value
    of an attribute.
    
    .. figure:: /_static/label01.png
      :align: center
      
    Simple display value
    ~~~~~~~~~~~~~~~~~~~~
    
    The simplest example of :class:`TauValueLabel`
    
    .. figure:: /_static/label01.png
      :align: center
      
    code::
    
        import sys
        from PyQt4 import Qt
        import tau.widget
    
        app = Qt.QApplication(sys.argv)
    
        w = tau.widget.TauValueLabel()
        w.setModel('sys/tautest/1/position')
    
        panel.setVisible(True)
        sys.exit(app.exec_())
    
    Hint:
        1. Try to execute the code above and place the mouse over the widget. After
           a couple of seconds an automatically generated tooltip will show up.
        2. Try to execute the code above and, without closing the tau application,
           change the format of the position attribute in the sys/tautest/1 from 6.2f 
           to 8.2f (using Jive, for example). Will will notice that the displayed value
           will change immediately (tango event system must be online in order for 
           this to work!).
    
    Using parent model
    ~~~~~~~~~~~~~~~~~~
    
    Demonstrates how to use the *showQuality* and *useParentModel* with 
    :class:`TauValueLabel` being inside another tau container: the :class:`TauWidget`
    
    .. figure:: /_static/label04.png
      :align: center
    
    code::
    
        import sys
        from PyQt4 import Qt
        import tau.widget
    
        app = Qt.QApplication(sys.argv)
        panel = tau.widget.TauWidget()
        layout = Qt.QVBoxLayout()
        panel.setLayout(layout)
        panel.setModel('sys/tautest/1')
        w1 = tau.widget.TauValueLabel()
        w2 = tau.widget.TauValueLabel()
        w3 = tau.widget.TauValueLabel()
        w1.setUseParentModel(True)
        w2.setUseParentModel(True)
        w3.setUseParentModel(True)
        w1.setModel('/state')
        w2.setModel('/position')
        w3.setModel('/simulationmode')
        w1.setShowQuality(False)
    
        layout.addWidget(w1)
        layout.addWidget(w2)
        layout.addWidget(w3)
        panel.setVisible(True)
    
        sys.exit(app.exec_())
    
    TauStateLabel tutorial
    ----------------------
    
    The :class:`TauStateLabel` is a tau widget designed to display the state of a
    device both with the background color.
    
    .. figure:: /_static/label05.png
      :align: center
    
    Because :class:`TauStateLabel` inherits from :class:`TauValueLabel`, all 
    :class:`TauValueLabel` properties are available.
    
    **model**:
        The model for the :class:`TauStateLabel` only accepts state attributes!
    
    **showQualityForeground**:
        - *Type*: bool
        - *Default value:* True
        - *Description*: When set to True, it uses the attribute quality to display
          the text foreground color
    
    Simple display state
    ~~~~~~~~~~~~~~~~~~~~
    
    The simplest example of :class:`TauStateLabel`
    
    .. figure:: /_static/label05.png
      :align: center
    
    code::
    
        import sys
        from PyQt4 import Qt
        import tau.widget
    
        app = Qt.QApplication(sys.argv)
        panel = Qt.QWidget()
        layout = Qt.QHBoxLayout()
        panel.setLayout(layout)
        w = tau.widget.TauStateLabel()
        w.setModel('sys/tautest/1/state')
        layout.addWidget(w)
        panel.setVisible(True)
    
        sys.exit(app.exec_())
    
    Array of state display
    ~~~~~~~~~~~~~~~~~~~~~~
    
    This example shows how to display multiple device states using a small area
    of the GUI.
    This example assumes there are 8 devices running with names: 'sys/tautest/<1-8>'
    
    .. figure:: /_static/label06.png
      :align: center
      
    code::
    
        import sys
        from PyQt4 import Qt
        import tau.widget
    
        app = Qt.QApplication(sys.argv)
        panel = Qt.QWidget()
        layout = Qt.QGridLayout()
        panel.setLayout(layout)
        for y in range(4):
            for x in range(2):
                w = tau.widget.TauStateLabel()
                w.setModel('sys/tautest/%d/state' % ((y+1)+4*x))
                w.setShowText(False)
                layout.addWidget(w,x,y)
        panel.setVisible(True)
    
        sys.exit(app.exec_())
    
    TauConfigLabel tutorial
    -----------------------
    
    @TODO
      
    .. _Tango: http://www.tango-controls.org/
    .. _PyTango: http://packages.python.org/PyTango/
    .. _QTango: http://www.tango-controls.org/download/index_html#qtango3
    .. _`PyTango installation steps`: http://packages.python.org/PyTango/start.html#getting-started
    .. _Qt: http://qt.nokia.com/products/
    .. _PyQt: http://www.riverbankcomputing.co.uk/software/pyqt/
    .. _PyQwt: http://pyqwt.sourceforge.net/
    .. _IPython: http://ipython.scipy.org/
    .. _ATK: http://www.tango-controls.org/Documents/gui/atk/tango-application-toolkit
    .. _Qub: http://www.blissgarden.org/projects/qub/
    .. _numpy: http://numpy.scipy.org/
    .. _SPEC: http://www.certif.com/
    .. _EPICS: http://www.aps.anl.gov/epics/