1
# Copyright (c) 2007, Enthought, Inc.
5
Implementation of a TextEditor demo plugin for the Traits UI demo program.
7
For each of three data types for which TextEditor is used, this demo shows
8
each of the four styles of the TextEditor.
13
import HasTraits, Str, Int, Password
16
import Item, Group, View
18
# The main demo class:
19
class TextEditorDemo ( HasTraits ):
20
""" Defines the TextEditor demo class.
23
# Define a trait for each of three TextEditor variants:
24
string_trait = Str( "sample string" )
28
# TextEditor display without multi-line capability (for various traits):
29
text_int_group = Group(
30
Item( 'int_trait', style = 'simple', label = 'Simple' ),
32
Item( 'int_trait', style = 'custom', label = 'Custom' ),
34
Item( 'int_trait', style = 'text', label = 'Text' ),
36
Item( 'int_trait', style = 'readonly', label = 'ReadOnly' ),
40
# TextEditor display with multi-line capability (for various traits):
41
text_str_group = Group(
42
Item( 'string_trait', style = 'simple', label = 'Simple' ),
44
Item( 'string_trait', style = 'custom', label = 'Custom' ),
46
Item( 'string_trait', style = 'text', label = 'Text' ),
48
Item( 'string_trait', style = 'readonly', label = 'ReadOnly' ),
52
# TextEditor display with secret typing capability (for Password traits):
53
text_pass_group = Group(
54
Item( 'password', style = 'simple', label = 'Simple' ),
56
Item( 'password', style = 'custom', label = 'Custom' ),
58
Item( 'password', style = 'text', label = 'Text' ),
60
Item( 'password', style = 'readonly', label = 'ReadOnly' ),
64
# The view includes one group per data type. These will be displayed
65
# on separate tabbed panels:
75
demo = TextEditorDemo()
77
# Run the demo (if invoked from the command line):
78
if __name__ == "__main__":
79
demo.configure_traits()