]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/Editor.py
1 # 11/17/2003 - Jeff Grimmett (grimmtooth@softhome.net)
3 # o Updated for wx namespace
5 # 11/28/2003 - Jeff Grimmett (grimmtooth@softhome.net)
7 # o editor lib hasn't been hit by the renamer yet.
9 # 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
11 # o wxEditor -> Editor
15 import wx
.lib
.editor
as editor
17 #----------------------------------------------------------------------
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)
25 win
.SetAutoLayout(True)
28 "This is a simple text editor, the class name is",
29 "Editor. Type a few lines and try it out.",
31 "It uses Windows-style key commands that can be overridden by subclassing.",
32 "Mouse select works. Here are the key commands:",
34 "Cursor movement: Arrow keys or mouse",
35 "Beginning of line: Home",
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",
47 #----------------------------------------------------------------------
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.
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.
62 The samples/FrogEdit directory has an example of a simple text editor
63 application that uses the Editor component.
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
77 if __name__
== '__main__':
80 run
.main(['', os
.path
.basename(sys
.argv
[0])])