~brian-sidebotham/wxwidgets-cmake/wxpython-2.9.4

1 by Brian Sidebotham
Initial import into Bazaar
1
import  wx
2
import  wx.lib.editor    as  editor
3
4
#----------------------------------------------------------------------
5
6
def runTest(frame, nb, log):
7
    win = wx.Panel(nb, -1)
8
    ed = editor.Editor(win, -1, style=wx.SUNKEN_BORDER)
9
    box = wx.BoxSizer(wx.VERTICAL)
10
    box.Add(ed, 1, wx.ALL|wx.GROW, 1)
11
    win.SetSizer(box)
12
    win.SetAutoLayout(True)
13
14
    ed.SetText(["",
15
                "This is a simple text editor, the class name is",
16
                "Editor.  Type a few lines and try it out.",
17
                "",
18
                "It uses Windows-style key commands that can be overridden by subclassing.",
19
                "Mouse select works. Here are the key commands:",
20
                "",
21
                "Cursor movement:     Arrow keys or mouse",
22
                "Beginning of line:   Home",
23
                "End of line:         End",
24
                "Beginning of buffer: Control-Home",
25
                "End of the buffer:   Control-End",
26
                "Select text:         Hold down Shift while moving the cursor",
27
                "Copy:                Control-Insert, Control-C",
28
                "Cut:                 Shift-Delete,   Control-X",
29
                "Paste:               Shift-Insert,   Control-V",
30
                ""])
31
32
    return win
33
34
#----------------------------------------------------------------------
35
36
37
overview = """
38
The Editor class implements a simple text editor using wxPython.  You
39
can create a custom editor by subclassing Editor.  Even though much of
40
the editor is implemented in Python, it runs surprisingly smoothly on
41
normal hardware with small files.
42
43
How to use it
44
-------------
45
The demo code (demo/Editor.py) shows how to use Editor as a simple text
46
box. Use the SetText() and GetText() methods to set or get text from
47
the component; these both use a list of strings.
48
49
The samples/FrogEdit directory has an example of a simple text editor
50
application that uses the Editor component.
51
52
Subclassing
53
-----------
54
To add or change functionality, you can subclass this
55
component. One example of this might be to change the key
56
Alt key commands. In that case you would (for example) override the
57
SetAltFuncs() method.
58
59
"""
60
61
62
63
64
if __name__ == '__main__':
65
    import sys,os
66
    import run
67
    run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
68
69