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