~ubuntu-branches/ubuntu/utopic/python-traitsui/utopic

« back to all changes in this revision

Viewing changes to examples/demo/Standard_Editors/Popup_versions/ButtonEditor_demo.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2011-07-09 13:57:39 UTC
  • Revision ID: james.westby@ubuntu.com-20110709135739-x5u20q86huissmn1
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""
 
2
Implementation of a ButtonEditor demo plugin for Traits UI demo program.
 
3
 
 
4
This demo shows each of the two styles of the ButtonEditor.
 
5
(As of this writing, they are identical.)
 
6
"""
 
7
 
 
8
from traits.api import HasTraits, Button
 
9
from traitsui.api import Item, View, Group
 
10
from traitsui.message import message
 
11
 
 
12
 
 
13
#-------------------------------------------------------------------------------
 
14
#  Demo Class
 
15
#-------------------------------------------------------------------------------
 
16
 
 
17
class ButtonEditorDemo ( HasTraits ):
 
18
    """ This class specifies the details of the ButtonEditor demo.
 
19
    """
 
20
 
 
21
    # To demonstrate any given Trait editor, an appropriate Trait is required.
 
22
    fire_event = Button('Click Me')
 
23
 
 
24
 
 
25
    def _fire_event_fired():
 
26
        message("Button clicked!")
 
27
 
 
28
 
 
29
 
 
30
    # ButtonEditor display
 
31
    # (Note that Text and ReadOnly versions are not applicable)
 
32
    event_group = Group( Item('fire_event', style='simple', label='Simple'),
 
33
                         Item('_'),
 
34
                         Item('fire_event', style='custom', label='Custom'),
 
35
                         Item('_'),
 
36
                         Item(label='[text style unavailable]'),
 
37
                         Item('_'),
 
38
                         Item(label='[read only style unavailable]'))
 
39
 
 
40
    # Demo view
 
41
    view1 = View( event_group,
 
42
                  title = 'ButtonEditor',
 
43
                  buttons = ['OK'],
 
44
                  width = 250 )
 
45
 
 
46
 
 
47
# Create the demo:
 
48
popup = ButtonEditorDemo()
 
49
 
 
50
# Run the demo (if invoked from the command line):
 
51
if __name__ == '__main__':
 
52
    popup.configure_traits()
 
53