]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/modules/lseditor/test/editor.py
lots'o' wxpython modules files
[wxWidgets.git] / utils / wxPython / modules / lseditor / test / editor.py
1 from wxPython.wx import *
2 from wxPython.lseditor import *
3
4 class LSEditorFrame(wxFrame):
5 def __init__(self, parent, id, title, pos = wxDefaultPosition, size = wxSize(400,400)):
6 wxFrame.__init__(self, parent, id, title, pos, size)
7 self.editor = wxsLSEditorPlugin()
8 self.editor.Create(self, -1)
9 self.SetMenuBar(self.GetDefaultMenuBar())
10 self.CreateStatusBar()
11 self.SetDefaultEvents()
12 self.filename = ""
13 def GetDefaultMenuBar(self):
14 mbar = wxMenuBar()
15 menu = wxMenu()
16 menu.Append(1500, "Open")
17 menu.Append(1501, "Save")
18 menu.Append(1502, "SaveAs")
19 menu.AppendSeparator()
20 menu.Append(1503, "Exit")
21 mbar.Append(menu, "File")
22 menu = wxMenu()
23 menu.Append(1510, "Copy")
24 menu.Append(1511, "Cut")
25 menu.Append(1512, "Paste")
26 menu.AppendSeparator()
27 menu.Append(1513, "Delete")
28 menu.AppendSeparator()
29 menu.Append(1514, "Undo")
30 menu.Append(1515, "Redo")
31 menu.AppendSeparator()
32 menu.Append(1516, "Find...")
33 menu.Append(1517, "Find Next")
34 menu.Append(1518, "Find Previous")
35 menu.Append(1519, "Replace...")
36 mbar.Append(menu, "Edit")
37 menu = wxMenu()
38 menu.Append(1520, "Toggle")
39 menu.Append(1521, "Next")
40 menu.Append(1522, "Prev")
41 mbar.Append(menu, "Bookmarks")
42 return mbar
43 def SetDefaultEvents(self):
44 EVT_MENU(self, 1500, self.evt_OnOpen)
45 EVT_MENU(self, 1501, self.evt_OnSave)
46 EVT_MENU(self, 1502, self.evt_OnSaveAs)
47 EVT_MENU(self, 1503, self.OnClose)
48 EVT_MENU(self, 1510, self.evt_OnCopy)
49 EVT_MENU(self, 1511, self.evt_OnCut)
50 EVT_MENU(self, 1512, self.evt_OnPaste)
51 EVT_MENU(self, 1513, self.evt_OnDelete)
52 EVT_MENU(self, 1514, self.evt_OnUndo)
53 EVT_MENU(self, 1515, self.evt_OnRedo)
54 EVT_MENU(self, 1516, self.evt_OnFind)
55 EVT_MENU(self, 1517, self.evt_OnFindNext)
56 EVT_MENU(self, 1518, self.evt_OnFindPrevious)
57 EVT_MENU(self, 1519, self.evt_OnReplace)
58 EVT_MENU(self, 1520, self.evt_OnToggle)
59 EVT_MENU(self, 1521, self.evt_OnNext)
60 EVT_MENU(self, 1522, self.evt_OnPrev)
61 #EVT_MENU(self, 15, self.evt_)
62 #EVT_MENU(self, 15, self.evt_)
63 def evt_OnOpen(self, event):
64 dlg = wxFileDialog(NULL, "Open file")
65 if dlg.ShowModal() == wxID_OK:
66 self.filename = dlg.GetPath()
67 self.editor.OnOpen(self.filename)
68 def evt_OnSaveAs(self, event):
69 dlg = wxFileDialog(NULL, "Save As", self.filename)
70 if dlg.ShowModal() == wxID_OK:
71 self.filename = dlg.GetPath()
72 self.editor.OnSave(self.filename)
73 def evt_OnSave(self, event):
74 if self.filename:
75 self.editor.OnSave(self.filename)
76 else:
77 self.evt_OnSaveAs(None)
78 def OnClose(self,event):
79 self.Destroy()
80 def evt_OnCopy(self,event):
81 self.editor.OnCopy()
82 def evt_OnCut(self,event):
83 self.editor.OnCut()
84 def evt_OnPaste(self,event):
85 self.editor.OnPaste()
86 def evt_OnDelete(self,event):
87 self.editor.OnDelete()
88 def evt_OnUndo(self,event):
89 self.editor.OnUndo()
90 def evt_OnRedo(self,event):
91 self.editor.OnRedo()
92 def evt_OnToggle(self,event):
93 self.editor.OnToggleBookmark()
94 def evt_OnNext(self,event):
95 self.editor.OnNextBookmark()
96 def evt_OnPrev(self,event):
97 self.editor.OnPreviousBookmark()
98 def evt_OnFind(self,event):
99 self.editor.OnFind()
100 def evt_OnFind(self,event):
101 self.editor.OnFind()
102 def evt_OnFindNext(self,event):
103 self.editor.OnFindNext()
104 def evt_OnFindPrevious(self,event):
105 self.editor.OnFindPrevious()
106 self.SetStatusText("OnFindPrevious: Not implemented")
107 def evt_OnReplace(self,event):
108 self.editor.OnReplace()
109 self.SetStatusText("OnReplace: Not implemented")
110
111 class MyApp(wxApp):
112 def OnInit(self):
113 frame = LSEditorFrame(NULL, -1, "Editor")
114 frame.Show(TRUE)
115 return TRUE
116
117 App = MyApp(0)
118 App.MainLoop()