]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/samples/frogedit/FrogEdit.py
newevent helpers
[wxWidgets.git] / wxPython / samples / frogedit / FrogEdit.py
index 68f3e27a049802a2194ff21398d615efbc87cc58..157b0e043e44006551fa54725733c5ef4187d722 100644 (file)
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python
+#!/usr/bin/env python
 
 # simple text editor
 #
 
 # simple text editor
 #
@@ -12,8 +12,6 @@ from wxPython.wx         import *
 from StatusBar           import *
 from FrogEditor          import FrogEditor
 
 from StatusBar           import *
 from FrogEditor          import FrogEditor
 
-TRUE  = 1
-FALSE = 0
 
 ABOUT_TEXT = """FrogEdit : Copyright 2001 Adam Feuer and Steve Howell
 wxEditor component : Copyright 1999 - 2001 Dirk Holtwic, Robin Dunn, Adam Feuer, Steve Howell
 
 ABOUT_TEXT = """FrogEdit : Copyright 2001 Adam Feuer and Steve Howell
 wxEditor component : Copyright 1999 - 2001 Dirk Holtwic, Robin Dunn, Adam Feuer, Steve Howell
@@ -36,7 +34,7 @@ class OutlinerPanel(wxPanel):
         wxPanel.Close(self)
 
 ##----------------------------------------------------------------------
         wxPanel.Close(self)
 
 ##----------------------------------------------------------------------
-    
+
 
 class FrogEditFrame(wxFrame):
     def __init__(self, parent, ID, title, pos=wxDefaultPosition,
 
 class FrogEditFrame(wxFrame):
     def __init__(self, parent, ID, title, pos=wxDefaultPosition,
@@ -48,7 +46,7 @@ class FrogEditFrame(wxFrame):
         win = OutlinerPanel(splitter, -1, style=wxCLIP_CHILDREN)
         win.parent = self
         log = self.MakeLogWindow(splitter)
         win = OutlinerPanel(splitter, -1, style=wxCLIP_CHILDREN)
         win.parent = self
         log = self.MakeLogWindow(splitter)
-        
+
         self.MakeStatusbar()
         self.MakeEditorWindow(win, log)
         self.SetUpSplitter(splitter, win, log)
         self.MakeStatusbar()
         self.MakeEditorWindow(win, log)
         self.SetUpSplitter(splitter, win, log)
@@ -57,6 +55,8 @@ class FrogEditFrame(wxFrame):
         self.RegisterEventHandlers()
         self.InitVariables()
 
         self.RegisterEventHandlers()
         self.InitVariables()
 
+        win.Layout()
+
 
 ##------------- Init Misc
 
 
 ##------------- Init Misc
 
@@ -66,7 +66,7 @@ class FrogEditFrame(wxFrame):
     def InitVariables(self):
         self.fileName = None
         self.edl.UnTouchBuffer()
     def InitVariables(self):
         self.fileName = None
         self.edl.UnTouchBuffer()
-        
+
     def MakeMenus(self):
         self.MainMenu = wxMenuBar()
         self.AddMenus(self.MainMenu)
     def MakeMenus(self):
         self.MainMenu = wxMenuBar()
         self.AddMenus(self.MainMenu)
@@ -93,7 +93,7 @@ class FrogEditFrame(wxFrame):
 
     def SetUpSplitter(self, splitter, win, log):
         splitter.SplitHorizontally(win, log)
 
     def SetUpSplitter(self, splitter, win, log):
         splitter.SplitHorizontally(win, log)
-        splitter.SetSashPosition(360, true)
+        splitter.SetSashPosition(360, True)
         splitter.SetMinimumPaneSize(40)
 
     def MakeToolbar(self, win):
         splitter.SetMinimumPaneSize(40)
 
     def MakeToolbar(self, win):
@@ -107,7 +107,7 @@ class FrogEditFrame(wxFrame):
         borderWidth = 5
         mainBox.Add(self.edl, 1, wxALL|wxGROW, borderWidth)
         win.SetSizer(mainBox)
         borderWidth = 5
         mainBox.Add(self.edl, 1, wxALL|wxGROW, borderWidth)
         win.SetSizer(mainBox)
-        win.SetAutoLayout(true)
+        win.SetAutoLayout(True)
 
 ##-------------- Init Menus
 
 
 ##-------------- Init Menus
 
@@ -172,15 +172,15 @@ class FrogEditFrame(wxFrame):
         messageDialog = wxMessageDialog(self, text, title, wxOK | wxICON_INFORMATION)
         messageDialog.ShowModal()
         messageDialog.Destroy()
         messageDialog = wxMessageDialog(self, text, title, wxOK | wxICON_INFORMATION)
         messageDialog.ShowModal()
         messageDialog.Destroy()
-    
+
     def OkCancelDialog(self, text, title):
         dialog = wxMessageDialog(self, text, title, wxOK | wxCANCEL | wxICON_INFORMATION)
         result = dialog.ShowModal()
         dialog.Destroy()
         if result == wxID_OK:
     def OkCancelDialog(self, text, title):
         dialog = wxMessageDialog(self, text, title, wxOK | wxCANCEL | wxICON_INFORMATION)
         result = dialog.ShowModal()
         dialog.Destroy()
         if result == wxID_OK:
-            return TRUE
+            return True
         else:
         else:
-            return FALSE
+            return False
 
     def SelectFileDialog(self, defaultDir=None, defaultFile=None, wildCard=None):
         if defaultDir == None:
 
     def SelectFileDialog(self, defaultDir=None, defaultFile=None, wildCard=None):
         if defaultDir == None:
@@ -191,11 +191,11 @@ class FrogEditFrame(wxFrame):
             wildCard = "*.*"
         fileName = None
         fileDialog = wxFileDialog(self, "Choose a file", defaultDir, defaultFile, wildCard, wxOPEN|wxMULTIPLE)
             wildCard = "*.*"
         fileName = None
         fileDialog = wxFileDialog(self, "Choose a file", defaultDir, defaultFile, wildCard, wxOPEN|wxMULTIPLE)
-        result = fileDialog.ShowModal() 
+        result = fileDialog.ShowModal()
         if result == wxID_OK:
             fileName = fileDialog.GetPath()
             wxLogMessage('You selected: %s\n' % fileName)
         if result == wxID_OK:
             fileName = fileDialog.GetPath()
             wxLogMessage('You selected: %s\n' % fileName)
-        fileDialog.Destroy()       
+        fileDialog.Destroy()
         return fileName
 
     def OpenFileError(self, fileName):
         return fileName
 
     def OpenFileError(self, fileName):
@@ -220,13 +220,13 @@ class FrogEditFrame(wxFrame):
 
     def SetAltFuncs(self, action):
         FrogEditor.SetAltFuncs(self.edl, action)
 
     def SetAltFuncs(self, action):
         FrogEditor.SetAltFuncs(self.edl, action)
-        action['x'] = self.OnFileExit 
+        action['x'] = self.OnFileExit
 
     def GetCurrentDir(self):
         if self.fileName is not None:
             return os.path.split(self.fileName)[0]
         return "."
 
     def GetCurrentDir(self):
         if self.fileName is not None:
             return os.path.split(self.fileName)[0]
         return "."
-            
+
     def GetFileName(self):
         if self.fileName is not None:
             return os.path.split(self.fileName)[1]
     def GetFileName(self):
         if self.fileName is not None:
             return os.path.split(self.fileName)[1]
@@ -245,9 +245,9 @@ class FrogEditFrame(wxFrame):
             f.close()
             self.edl.UnTouchBuffer()
             self.sb.setFileName(fileName)
             f.close()
             self.edl.UnTouchBuffer()
             self.sb.setFileName(fileName)
-            return TRUE
+            return True
         except:
         except:
-            return FALSE
+            return False
 
     def OpenFile(self, fileName):
         try:
 
     def OpenFile(self, fileName):
         try:
@@ -260,10 +260,10 @@ class FrogEditFrame(wxFrame):
             self.edl.SetText(contents)
             self.fileName = fileName
             self.sb.setFileName(fileName)
             self.edl.SetText(contents)
             self.fileName = fileName
             self.sb.setFileName(fileName)
-            return TRUE
+            return True
         except:
         except:
-            return FALSE
-        
+            return False
+
 
 
 ##---------------- Event handlers
 
 
 ##---------------- Event handlers
@@ -279,35 +279,35 @@ class FrogEditFrame(wxFrame):
                 return
         self.NewFile()
         self.edl.SetFocus()
                 return
         self.NewFile()
         self.edl.SetFocus()
-    
+
     def OnOpenFile(self, event):
         if self.edl.BufferWasTouched():
             if not self.OkCancelDialog("Open file - abandon changes?", "Open File"):
                 return
         fileName = self.SelectFileDialog(self.GetCurrentDir())
         if fileName is not None:
     def OnOpenFile(self, event):
         if self.edl.BufferWasTouched():
             if not self.OkCancelDialog("Open file - abandon changes?", "Open File"):
                 return
         fileName = self.SelectFileDialog(self.GetCurrentDir())
         if fileName is not None:
-            if self.OpenFile(fileName) is FALSE:
+            if self.OpenFile(fileName) is False:
                 self.OpenFileError(fileName)
         self.edl.SetFocus()
                 self.OpenFileError(fileName)
         self.edl.SetFocus()
-    
+
     def OnSaveFile(self, event):
         if self.fileName is None:
             return self.OnSaveFileAs(event)
         wxLogMessage("Saving %s..." % self.fileName)
     def OnSaveFile(self, event):
         if self.fileName is None:
             return self.OnSaveFileAs(event)
         wxLogMessage("Saving %s..." % self.fileName)
-        if self.SaveFile(self.fileName) is not TRUE:
+        if self.SaveFile(self.fileName) is not True:
             self.SaveFileError(self.fileName)
         self.edl.SetFocus()
             self.SaveFileError(self.fileName)
         self.edl.SetFocus()
-    
+
     def OnSaveFileAs(self, event):
         fileName = self.SelectFileDialog(self.GetCurrentDir(),self.GetFileName())
         if fileName is not None:
             self.fileName = fileName
             wxLogMessage("Saving %s..." % self.fileName)
     def OnSaveFileAs(self, event):
         fileName = self.SelectFileDialog(self.GetCurrentDir(),self.GetFileName())
         if fileName is not None:
             self.fileName = fileName
             wxLogMessage("Saving %s..." % self.fileName)
-            if self.SaveFile(self.fileName) is not TRUE:
+            if self.SaveFile(self.fileName) is not True:
                 self.SaveFileError(self.fileName)
         self.edl.SetFocus()
                 self.SaveFileError(self.fileName)
         self.edl.SetFocus()
-    
-    def OnFileExit(self, event):        
+
+    def OnFileExit(self, event):
         if self.edl.BufferWasTouched():
             if not self.OkCancelDialog("Exit program - abandon changes?", "Exit"):
                 return
         if self.edl.BufferWasTouched():
             if not self.OkCancelDialog("Exit program - abandon changes?", "Exit"):
                 return
@@ -316,11 +316,11 @@ class FrogEditFrame(wxFrame):
     def OnEditPreferences(self, event):
         self.MessageDialog("Edit preferences is not implemented yet.", "Not implemented.")
         pass
     def OnEditPreferences(self, event):
         self.MessageDialog("Edit preferences is not implemented yet.", "Not implemented.")
         pass
-    
+
     def OnHelpAbout(self, event):
         self.MessageDialog(ABOUT_TEXT, "About FrogEdit")
         pass
     def OnHelpAbout(self, event):
         self.MessageDialog(ABOUT_TEXT, "About FrogEdit")
         pass
-    
+
     def Show(self, show):
         wxFrame.Show(self, show)
         self.edl.SetFocus()
     def Show(self, show):
         wxFrame.Show(self, show)
         self.edl.SetFocus()
@@ -329,8 +329,8 @@ class FrogEditFrame(wxFrame):
 
     def LoadInitialFile(self, fileName):
         if fileName is not None:
 
     def LoadInitialFile(self, fileName):
         if fileName is not None:
-            if self.OpenFile(fileName) is FALSE:
-                self.OpenFileError(fileName)        
+            if self.OpenFile(fileName) is False:
+                self.OpenFileError(fileName)
 
 
 
 
 
 
@@ -341,7 +341,8 @@ class FrogEditLauncher:
 
     def MakeAppFrame(self):
         return FrogEditFrame(None, -1, "FrogEdit", size=(640, 480),
 
     def MakeAppFrame(self):
         return FrogEditFrame(None, -1, "FrogEdit", size=(640, 480),
-                             style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)    
+                             style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
+
     def GetArgvFilename(self):
         if len(sys.argv) > 1:
             return sys.argv[1]
     def GetArgvFilename(self):
         if len(sys.argv) > 1:
             return sys.argv[1]
@@ -349,9 +350,9 @@ class FrogEditLauncher:
             return None
 
     def Main(self):
             return None
 
     def Main(self):
-        win = self.MakeAppFrame()
         app = wxPySimpleApp()
         app = wxPySimpleApp()
-        win.Show(true)
+        win = self.MakeAppFrame()
+        win.Show(True)
         win.LoadInitialFile(self.GetArgvFilename())
         app.MainLoop()
 
         win.LoadInitialFile(self.GetArgvFilename())
         app.MainLoop()
 
@@ -363,4 +364,3 @@ if __name__ == '__main__':
 
     launcher = FrogEditLauncher()
     launcher.Main()
 
     launcher = FrogEditLauncher()
     launcher.Main()
-