]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/wxPython/src/_extras.py
Compilation fixes
[wxWidgets.git] / utils / wxPython / src / _extras.py
index 686803f320c2c1b47c66a7e73398b098a4a2a8e8..a3d76e54f53c99d6f6014355f307a5585012f46d 100644 (file)
@@ -29,12 +29,6 @@ def _checkForCallback(obj, name, event, theID=-1):
     except: pass
     else:   obj.Connect(theID, -1, event, cb)
 
     except: pass
     else:   obj.Connect(theID, -1, event, cb)
 
-##  def _checkClassCallback(obj, name):
-##      try:    cb = getattr(obj, name)
-##      except: pass
-##      else:   obj._addCallback(name, cb)
-
-
 def _StdWindowCallbacks(win):
     _checkForCallback(win, "OnChar",               wxEVT_CHAR)
     _checkForCallback(win, "OnSize",               wxEVT_SIZE)
 def _StdWindowCallbacks(win):
     _checkForCallback(win, "OnChar",               wxEVT_CHAR)
     _checkForCallback(win, "OnSize",               wxEVT_SIZE)
@@ -230,6 +224,7 @@ def EVT_COMMAND(win, id, cmd, func):
 def EVT_COMMAND_RANGE(win, id1, id2, cmd, func):
     win.Connect(id1, id2, cmd, func)
 
 def EVT_COMMAND_RANGE(win, id1, id2, cmd, func):
     win.Connect(id1, id2, cmd, func)
 
+
 # Scrolling
 def EVT_SCROLL(win, func):
     win.Connect(-1, -1, wxEVT_SCROLL_TOP,       func)
 # Scrolling
 def EVT_SCROLL(win, func):
     win.Connect(-1, -1, wxEVT_SCROLL_TOP,       func)
@@ -239,6 +234,7 @@ def EVT_SCROLL(win, func):
     win.Connect(-1, -1, wxEVT_SCROLL_PAGEUP,    func)
     win.Connect(-1, -1, wxEVT_SCROLL_PAGEDOWN,  func)
     win.Connect(-1, -1, wxEVT_SCROLL_THUMBTRACK,func)
     win.Connect(-1, -1, wxEVT_SCROLL_PAGEUP,    func)
     win.Connect(-1, -1, wxEVT_SCROLL_PAGEDOWN,  func)
     win.Connect(-1, -1, wxEVT_SCROLL_THUMBTRACK,func)
+    win.Connect(-1, -1, wxEVT_SCROLL_THUMBRELEASE,func)
 
 def EVT_SCROLL_TOP(win, func):
     win.Connect(-1, -1, wxEVT_SCROLL_TOP, func)
 
 def EVT_SCROLL_TOP(win, func):
     win.Connect(-1, -1, wxEVT_SCROLL_TOP, func)
@@ -261,6 +257,9 @@ def EVT_SCROLL_PAGEDOWN(win, func):
 def EVT_SCROLL_THUMBTRACK(win, func):
     win.Connect(-1, -1, wxEVT_SCROLL_THUMBTRACK, func)
 
 def EVT_SCROLL_THUMBTRACK(win, func):
     win.Connect(-1, -1, wxEVT_SCROLL_THUMBTRACK, func)
 
+def EVT_SCROLL_THUMBRELEASE(win, func):
+    win.Connect(-1, -1, wxEVT_SCROLL_THUMBRELEASE, func)
+
 
 
 # Scrolling, with an id
 
 
 # Scrolling, with an id
@@ -272,6 +271,7 @@ def EVT_COMMAND_SCROLL(win, id, func):
     win.Connect(id, -1, wxEVT_SCROLL_PAGEUP,    func)
     win.Connect(id, -1, wxEVT_SCROLL_PAGEDOWN,  func)
     win.Connect(id, -1, wxEVT_SCROLL_THUMBTRACK,func)
     win.Connect(id, -1, wxEVT_SCROLL_PAGEUP,    func)
     win.Connect(id, -1, wxEVT_SCROLL_PAGEDOWN,  func)
     win.Connect(id, -1, wxEVT_SCROLL_THUMBTRACK,func)
+    win.Connect(id, -1, wxEVT_SCROLL_THUMBRELEASE,func)
 
 def EVT_COMMAND_SCROLL_TOP(win, id, func):
     win.Connect(id, -1, wxEVT_SCROLL_TOP, func)
 
 def EVT_COMMAND_SCROLL_TOP(win, id, func):
     win.Connect(id, -1, wxEVT_SCROLL_TOP, func)
@@ -294,15 +294,19 @@ def EVT_COMMAND_SCROLL_PAGEDOWN(win, id, func):
 def EVT_COMMAND_SCROLL_THUMBTRACK(win, id, func):
     win.Connect(id, -1, wxEVT_SCROLL_THUMBTRACK, func)
 
 def EVT_COMMAND_SCROLL_THUMBTRACK(win, id, func):
     win.Connect(id, -1, wxEVT_SCROLL_THUMBTRACK, func)
 
+def EVT_COMMAND_SCROLL_THUMBRELEASE(win, id, func):
+    win.Connect(id, -1, wxEVT_SCROLL_THUMBRELEASE, func)
+
 #---
 def EVT_SCROLLWIN(win, func):
 #---
 def EVT_SCROLLWIN(win, func):
-    win.Connect(-1, -1, wxEVT_SCROLLWIN_TOP,       func)
-    win.Connect(-1, -1, wxEVT_SCROLLWIN_BOTTOM,    func)
-    win.Connect(-1, -1, wxEVT_SCROLLWIN_LINEUP,    func)
-    win.Connect(-1, -1, wxEVT_SCROLLWIN_LINEDOWN,  func)
-    win.Connect(-1, -1, wxEVT_SCROLLWIN_PAGEUP,    func)
-    win.Connect(-1, -1, wxEVT_SCROLLWIN_PAGEDOWN,  func)
-    win.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBTRACK,func)
+    win.Connect(-1, -1, wxEVT_SCROLLWIN_TOP,         func)
+    win.Connect(-1, -1, wxEVT_SCROLLWIN_BOTTOM,      func)
+    win.Connect(-1, -1, wxEVT_SCROLLWIN_LINEUP,      func)
+    win.Connect(-1, -1, wxEVT_SCROLLWIN_LINEDOWN,    func)
+    win.Connect(-1, -1, wxEVT_SCROLLWIN_PAGEUP,      func)
+    win.Connect(-1, -1, wxEVT_SCROLLWIN_PAGEDOWN,    func)
+    win.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBTRACK,  func)
+    win.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBRELEASE,func)
 
 def EVT_SCROLLWIN_TOP(win, func):
     win.Connect(-1, -1, wxEVT_SCROLLWIN_TOP, func)
 
 def EVT_SCROLLWIN_TOP(win, func):
     win.Connect(-1, -1, wxEVT_SCROLLWIN_TOP, func)
@@ -325,17 +329,21 @@ def EVT_SCROLLWIN_PAGEDOWN(win, func):
 def EVT_SCROLLWIN_THUMBTRACK(win, func):
     win.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBTRACK, func)
 
 def EVT_SCROLLWIN_THUMBTRACK(win, func):
     win.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBTRACK, func)
 
+def EVT_SCROLLWIN_THUMBRELEASE(win, func):
+    win.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBRELEASE, func)
+
 
 
 # Scrolling, with an id
 def EVT_COMMAND_SCROLLWIN(win, id, func):
 
 
 # Scrolling, with an id
 def EVT_COMMAND_SCROLLWIN(win, id, func):
-    win.Connect(id, -1, wxEVT_SCROLLWIN_TOP,       func)
-    win.Connect(id, -1, wxEVT_SCROLLWIN_BOTTOM,    func)
-    win.Connect(id, -1, wxEVT_SCROLLWIN_LINEUP,    func)
-    win.Connect(id, -1, wxEVT_SCROLLWIN_LINEDOWN,  func)
-    win.Connect(id, -1, wxEVT_SCROLLWIN_PAGEUP,    func)
-    win.Connect(id, -1, wxEVT_SCROLLWIN_PAGEDOWN,  func)
-    win.Connect(id, -1, wxEVT_SCROLLWIN_THUMBTRACK,func)
+    win.Connect(id, -1, wxEVT_SCROLLWIN_TOP,         func)
+    win.Connect(id, -1, wxEVT_SCROLLWIN_BOTTOM,      func)
+    win.Connect(id, -1, wxEVT_SCROLLWIN_LINEUP,      func)
+    win.Connect(id, -1, wxEVT_SCROLLWIN_LINEDOWN,    func)
+    win.Connect(id, -1, wxEVT_SCROLLWIN_PAGEUP,      func)
+    win.Connect(id, -1, wxEVT_SCROLLWIN_PAGEDOWN,    func)
+    win.Connect(id, -1, wxEVT_SCROLLWIN_THUMBTRACK,  func)
+    win.Connect(id, -1, wxEVT_SCROLLWIN_THUMBRELEASE,func)
 
 def EVT_COMMAND_SCROLLWIN_TOP(win, id, func):
     win.Connect(id, -1, wxEVT_SCROLLWIN_TOP, func)
 
 def EVT_COMMAND_SCROLLWIN_TOP(win, id, func):
     win.Connect(id, -1, wxEVT_SCROLLWIN_TOP, func)
@@ -358,6 +366,10 @@ def EVT_COMMAND_SCROLLWIN_PAGEDOWN(win, id, func):
 def EVT_COMMAND_SCROLLWIN_THUMBTRACK(win, id, func):
     win.Connect(id, -1, wxEVT_SCROLLWIN_THUMBTRACK, func)
 
 def EVT_COMMAND_SCROLLWIN_THUMBTRACK(win, id, func):
     win.Connect(id, -1, wxEVT_SCROLLWIN_THUMBTRACK, func)
 
+def EVT_COMMAND_SCROLLWIN_THUMBRELEASE(win, id, func):
+    win.Connect(id, -1, wxEVT_SCROLLWIN_THUMBRELEASE, func)
+
+
 # Convenience commands
 def EVT_BUTTON(win, id, func):
     win.Connect(id, -1, wxEVT_COMMAND_BUTTON_CLICKED, func)
 # Convenience commands
 def EVT_BUTTON(win, id, func):
     win.Connect(id, -1, wxEVT_COMMAND_BUTTON_CLICKED, func)
@@ -733,15 +745,18 @@ class wxPyOnDemandOutputWindow:
         self.frame  = None
         self.title  = title
 
         self.frame  = None
         self.title  = title
 
+
     def SetParent(self, parent):
         self.parent = parent
 
     def SetParent(self, parent):
         self.parent = parent
 
+
     def OnCloseWindow(self, event):
         if self.frame != None:
             self.frame.Destroy()
         self.frame = None
         self.text  = None
 
     def OnCloseWindow(self, event):
         if self.frame != None:
             self.frame.Destroy()
         self.frame = None
         self.text  = None
 
+
     # this provides the file-like behaviour
     def write(self, str):
         if not self.frame:
     # this provides the file-like behaviour
     def write(self, str):
         if not self.frame:
@@ -753,7 +768,10 @@ class wxPyOnDemandOutputWindow:
             EVT_CLOSE(self.frame, self.OnCloseWindow)
         self.text.AppendText(str)
 
             EVT_CLOSE(self.frame, self.OnCloseWindow)
         self.text.AppendText(str)
 
+
     def close(self):
     def close(self):
+        if self.frame != None:
+            self.frame.Destroy()
         self.frame = None
         self.text  = None
 
         self.frame = None
         self.text  = None
 
@@ -789,19 +807,22 @@ class wxApp(wxPyApp):
     def SetTopWindow(self, frame):
         if self.stdioWin:
             self.stdioWin.SetParent(frame)
     def SetTopWindow(self, frame):
         if self.stdioWin:
             self.stdioWin.SetParent(frame)
-            sys.stdout = self.stdioWin #sys.stderr =
+            sys.stderr = sys.stdout = self.stdioWin
         wxPyApp.SetTopWindow(self, frame)
 
         wxPyApp.SetTopWindow(self, frame)
 
+
     def MainLoop(self):
         wxPyApp.MainLoop(self)
         self.RestoreStdio()
 
     def MainLoop(self):
         wxPyApp.MainLoop(self)
         self.RestoreStdio()
 
+
     def RedirectStdio(self, filename):
         if filename:
             sys.stdout = sys.stderr = open(filename, 'a')
         else:
             self.stdioWin = self.outputWindowClass() # wxPyOnDemandOutputWindow
 
     def RedirectStdio(self, filename):
         if filename:
             sys.stdout = sys.stderr = open(filename, 'a')
         else:
             self.stdioWin = self.outputWindowClass() # wxPyOnDemandOutputWindow
 
+
     def RestoreStdio(self):
         sys.stdout, sys.stderr = self.saveStdio
         if self.stdioWin != None:
     def RestoreStdio(self):
         sys.stdout, sys.stderr = self.saveStdio
         if self.stdioWin != None: