/usr/share/doc/python-traits/examples/tutorials/doc_examples/examples/widget.py is in python-traits 4.1.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # Copyright (c) 2007, Enthought, Inc.
# License: BSD Style.
from traits.api import Float, HasTraits, Trait
class Part(HasTraits):
cost = Trait(0.0)
class Widget(HasTraits):
part1 = Trait(Part)
part2 = Trait(Part)
cost = Float(0.0)
def __init__(self):
self.part1 = Part()
self.part2 = Part()
self.part1.on_trait_change(self.update_cost, 'cost')
self.part2.on_trait_change(self.update_cost, 'cost')
def update_cost(self):
self.cost = self.part1.cost + self.part2.cost
|