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