Custom Controls → Editor
overview = """\
The Editor class implements a simple text editor using wxPython. You
can create a custom editor by subclassing Editor. Even though much of
the editor is implemented in Python, it runs surprisingly smoothly on
normal hardware with small files.
"""
import wx
import wx.lib.editor
class Frame(wx.Frame):
def __init__(
self, parent=None, id=wx.ID_ANY, title='wx.lib.editor.Editor', pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE
):
wx.Frame.__init__(self, parent, id, title, pos, size, style)
self.SetIcon(wx.Icon('wxWidgets.ico', wx.BITMAP_TYPE_ICO))
# panel = wx.Panel(self, wx.ID_ANY)
editor = wx.lib.editor.Editor(self, wx.ID_ANY, pos=(0, 0), style=wx.SUNKEN_BORDER)
editor.SetText(["",
"This is a simple text editor, the class name is",
"Editor. Type a few lines and try it out.",
"",
"It uses Windows-style key commands that can be overridden by subclassing.",
"Mouse select works. Here are the key commands:",
"Cursor movement: Arrow keys or mouse",
"Beginning of line: Home",
"End of line: End",
"Beginning of buffer: Control-Home",
"End of the buffer: Control-End",
"Select text: Hold down Shift while moving the cursor",
"Copy: Control-Insert, Control-C",
"Cut: Shift-Delete, Control-X",
"Paste: Shift-Insert, Control-V",
""])
def TestFrame():
app = wx.PySimpleApp()
frame = Frame(size=(480, 400))
frame.Centre()
frame.Show()
app.MainLoop()
if __name__ == '__main__':
TestFrame()