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

« back to all changes in this revision

Viewing changes to integrationtests/ui/html_editor_test.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
#
 
3
#  Test case for the HTMLEditor.
 
4
#
 
5
#  Written by: David C. Morrill
 
6
#
 
7
#  Date: 09/22/2005
 
8
#
 
9
#  (c) Copyright 2005 by Enthought, Inc.
 
10
#  License: BSD Style.
 
11
#
 
12
#-------------------------------------------------------------------------------
 
13
 
 
14
#-------------------------------------------------------------------------------
 
15
#  Imports:
 
16
#-------------------------------------------------------------------------------
 
17
 
 
18
from traits.api \
 
19
    import HasPrivateTraits, Code
 
20
 
 
21
from traitsui.api \
 
22
    import View, Group, Item, HTMLEditor
 
23
 
 
24
#-------------------------------------------------------------------------------
 
25
#  Constants:
 
26
#-------------------------------------------------------------------------------
 
27
 
 
28
sample = """This is a code block:
 
29
 
 
30
    def foo ( bar ):
 
31
        print 'bar:', bar
 
32
 
 
33
This is an unordered list:
 
34
 - An
 
35
 - unordered
 
36
 - list
 
37
 
 
38
This is an ordered list:
 
39
 * One
 
40
 * Two
 
41
 * Three
 
42
 
 
43
Lists can be nested:
 
44
 * One
 
45
   * 1.1
 
46
   * 1.2
 
47
 * Two
 
48
   * 2.1
 
49
   * 2.2
 
50
"""
 
51
 
 
52
#-------------------------------------------------------------------------------
 
53
#  'TestHTML' class:
 
54
#-------------------------------------------------------------------------------
 
55
 
 
56
class TestHTML ( HasPrivateTraits ):
 
57
 
 
58
    #---------------------------------------------------------------------------
 
59
    #  Trait definitions:
 
60
    #---------------------------------------------------------------------------
 
61
 
 
62
    # Text string to display as HTML:
 
63
    html = Code( sample )
 
64
 
 
65
    #---------------------------------------------------------------------------
 
66
    #  Traits view definitions:
 
67
    #---------------------------------------------------------------------------
 
68
 
 
69
    view = View( Group(
 
70
                     [ Item( 'html#@', editor = HTMLEditor() ), '|<>' ],
 
71
                     [ '{Enter formatted text and/or HTML below:}@',
 
72
                       'html#@', '|<>' ],
 
73
                     '|<>', layout = 'split' ),
 
74
                 title     = 'HTML Editor Test',
 
75
                 resizable = True,
 
76
                 width     = 0.4,
 
77
                 height    = 0.6 )
 
78
 
 
79
#-------------------------------------------------------------------------------
 
80
#  Run the test:
 
81
#-------------------------------------------------------------------------------
 
82
 
 
83
if __name__ == '__main__':
 
84
    TestHTML().configure_traits()