Revision: 5906
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5906&view=rev
Author:   pkienzle
Date:     2008-07-27 20:42:13 +0000 (Sun, 27 Jul 2008)

Log Message:
-----------
Fix wx event loops

Modified Paths:
--------------
    trunk/matplotlib/lib/matplotlib/backends/backend_wx.py

Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py      2008-07-27 
20:36:10 UTC (rev 5905)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py      2008-07-27 
20:42:13 UTC (rev 5906)
@@ -719,9 +719,6 @@
         bind(self, wx.EVT_LEAVE_WINDOW, self._onLeave)
         bind(self, wx.EVT_IDLE, self._onIdle)
 
-        # Event loop handler for start/stop event loop
-        self._event_loop = wx.EventLoop()
-
         self.macros = {} # dict from wx id to seq of macros
 
         self.Printer_Init()
@@ -932,12 +929,19 @@
         This call blocks until a callback function triggers
         stop_event_loop() or *timeout* is reached.  If *timeout* is
         <=0, never timeout.
+
+        Raises RuntimeError if event loop is already running.
         """
+        if hasattr(self, '_event_loop'):
+            raise RuntimeError("Event loop already running")
         id = wx.NewId()
         timer = wx.Timer(self, id=id)
         if timeout > 0:
             timer.Start(timeout*1000, oneShot=True)
             bind(self, wx.EVT_TIMER, self.stop_event_loop, id=id)
+
+        # Event loop handler for start/stop event loop
+        self._event_loop = wx.EventLoop()
         self._event_loop.Run()
         timer.Stop()
 
@@ -951,8 +955,10 @@
 
         stop_event_loop_default(self)
         """
-        if self._event_loop.IsRunning():
-            self._event_loop.Exit()
+        if hasattr(self,'_event_loop'):
+            if self._event_loop.IsRunning():
+                self._event_loop.Exit()
+            del self._event_loop
 
 
     def _get_imagesave_wildcards(self):


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to