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

« back to all changes in this revision

Viewing changes to examples/tutorials/doc_examples/examples/handler_override.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
#  Copyright (c) 2007, Enthought, Inc.
 
2
#  License: BSD Style.
 
3
 
 
4
# handler_override.py -- Example of a Handler that overrides setattr(), and
 
5
#                        that has a user interface notification method
 
6
 
 
7
#--[Imports]--------------------------------------------------------------------
 
8
 
 
9
from traits.api import HasTraits, Bool
 
10
from traitsui.api import View, Handler
 
11
 
 
12
#--[Code]-----------------------------------------------------------------------
 
13
 
 
14
class TC_Handler(Handler):
 
15
 
 
16
    def setattr(self, info, object, name, value):
 
17
        Handler.setattr(self, info, object, name, value)
 
18
        info.object._updated = True
 
19
 
 
20
    def object__updated_changed(self, info):
 
21
        if info.initialized:
 
22
            info.ui.title += "*"
 
23
 
 
24
class TestClass(HasTraits):
 
25
    b1 = Bool
 
26
    b2 = Bool
 
27
    b3 = Bool
 
28
    _updated = Bool(False)
 
29
 
 
30
view1 = View('b1', 'b2', 'b3',
 
31
             title="Alter Title",
 
32
             handler=TC_Handler(),
 
33
             buttons = ['OK', 'Cancel'])
 
34
 
 
35
tc = TestClass()
 
36
tc.configure_traits(view=view1)
 
37