From: <pki...@us...> - 2008-07-24 15:39:44
|
Revision: 5840 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5840&view=rev Author: pkienzle Date: 2008-07-24 15:39:41 +0000 (Thu, 24 Jul 2008) Log Message: ----------- Use bind() function to hide wx version differences 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-24 14:54:22 UTC (rev 5839) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-07-24 15:39:41 UTC (rev 5840) @@ -145,6 +145,16 @@ # WxLogger =wx.LogStderr() # sys.stderr = fake_stderr +# Event binding code changed after version 2.5 +if wx.VERSION_STRING >= '2.5': + def bind(actor,event,action,**kw): + actor.Bind(event,action,**kw) +else: + def bind(actor,event,action,id=None): + if id is not None: + event(actor, id, action) + else: + event(actor,action) import matplotlib from matplotlib import verbose @@ -161,10 +171,6 @@ from matplotlib.widgets import SubplotTool from matplotlib import rcParams -##import wx -##backend_version = wx.VERSION_STRING - - # the True dots per inch on the screen; should be display dependent # see http://groups.google.com/groups?q=screen+dpi+x11&hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&selm=7077.26e81ad5%40swift.cs.tcd.ie&rnum=5 for some info about screen dpi PIXELS_PER_INCH = 75 @@ -698,40 +704,21 @@ self._isConfigured = False self._printQued = [] - if wx.VERSION_STRING >= '2.5': - # Event handlers 2.5 - self.Bind(wx.EVT_SIZE, self._onSize) - self.Bind(wx.EVT_PAINT, self._onPaint) - self.Bind(wx.EVT_KEY_DOWN, self._onKeyDown) - self.Bind(wx.EVT_KEY_UP, self._onKeyUp) - self.Bind(wx.EVT_RIGHT_DOWN, self._onRightButtonDown) - self.Bind(wx.EVT_RIGHT_DCLICK, self._onRightButtonDown) - self.Bind(wx.EVT_RIGHT_UP, self._onRightButtonUp) - self.Bind(wx.EVT_MOUSEWHEEL, self._onMouseWheel) - self.Bind(wx.EVT_LEFT_DOWN, self._onLeftButtonDown) - self.Bind(wx.EVT_LEFT_DCLICK, self._onLeftButtonDown) - self.Bind(wx.EVT_LEFT_UP, self._onLeftButtonUp) - self.Bind(wx.EVT_MOTION, self._onMotion) - self.Bind(wx.EVT_LEAVE_WINDOW, self._onLeave) - self.Bind(wx.EVT_IDLE, self._onIdle) - else: - # Event handlers 2.4 - wx.EVT_SIZE(self, self._onSize) - wx.EVT_PAINT(self, self._onPaint) - wx.EVT_KEY_DOWN(self, self._onKeyDown) - wx.EVT_KEY_UP(self, self._onKeyUp) - wx.EVT_RIGHT_DOWN(self, self._onRightButtonDown) - wx.EVT_RIGHT_DCLICK(self, self._onRightButtonDown) - wx.EVT_RIGHT_UP(self, self._onRightButtonUp) - wx.EVT_MOUSEWHEEL(self, self._onMouseWheel) - wx.EVT_LEFT_DOWN(self, self._onLeftButtonDown) - wx.EVT_LEFT_DCLICK(self, self._onLeftButtonDown) - wx.EVT_LEFT_UP(self, self._onLeftButtonUp) - wx.EVT_MOTION(self, self._onMotion) - wx.EVT_LEAVE_WINDOW(self, self._onLeave) - wx.EVT_IDLE(self, self._onIdle) + bind(self, wx.EVT_SIZE, self._onSize) + bind(self, wx.EVT_PAINT, self._onPaint) + bind(self, wx.EVT_KEY_DOWN, self._onKeyDown) + bind(self, wx.EVT_KEY_UP, self._onKeyUp) + bind(self, wx.EVT_RIGHT_DOWN, self._onRightButtonDown) + bind(self, wx.EVT_RIGHT_DCLICK, self._onRightButtonDown) + bind(self, wx.EVT_RIGHT_UP, self._onRightButtonUp) + bind(self, wx.EVT_MOUSEWHEEL, self._onMouseWheel) + bind(self, wx.EVT_LEFT_DOWN, self._onLeftButtonDown) + bind(self, wx.EVT_LEFT_DCLICK, self._onLeftButtonDown) + bind(self, wx.EVT_LEFT_UP, self._onLeftButtonUp) + bind(self, wx.EVT_MOTION, self._onMotion) + bind(self, wx.EVT_LEAVE_WINDOW, self._onLeave) + bind(self, wx.EVT_IDLE, self._onIdle) - self._event_loop = wx.EventLoop() self.macros = {} # dict from wx id to seq of macros @@ -1225,17 +1212,6 @@ if figManager is not None: figManager.canvas.draw() -# Event binding code changed after version 2.5 -if wx.VERSION_STRING >= '2.5': - def bind(actor,event,action,**kw): - actor.Bind(event,action,**kw) -else: - def bind(actor,event,action,id=None): - if id is not None: - event(actor, id, action) - else: - event(actor,action) - def show(): """ Current implementation assumes that matplotlib is executed in a PyCrust @@ -1333,12 +1309,7 @@ self.figmgr = FigureManagerWx(self.canvas, num, self) - if wx.VERSION_STRING >= '2.5': - # Event handlers 2.5 - self.Bind(wx.EVT_CLOSE, self._onClose) - else: - # Event handlers 2.4 - wx.EVT_CLOSE(self, self._onClose) + bind(self, wx.EVT_CLOSE, self._onClose) def _get_toolbar(self, statbar): if matplotlib.rcParams['toolbar']=='classic': @@ -1485,14 +1456,9 @@ self._menu.Append(self._invertId, "Invert", "Invert axes selected", False) self._menu.AppendSeparator() - if wx.VERSION_STRING >= '2.5': - self.Bind(wx.EVT_BUTTON, self._onMenuButton, id=_NTB_AXISMENU_BUTTON) - self.Bind(wx.EVT_MENU, self._handleSelectAllAxes, id=self._allId) - self.Bind(wx.EVT_MENU, self._handleInvertAxesSelected, id=self._invertId) - else: - wx.EVT_BUTTON(self, _NTB_AXISMENU_BUTTON, self._onMenuButton) - wx.EVT_MENU(self, self._allId, self._handleSelectAllAxes) - wx.EVT_MENU(self, self._invertId, self._handleInvertAxesSelected) + bind(self, wx.EVT_BUTTON, self._onMenuButton, id=_NTB_AXISMENU_BUTTON) + bind(self, wx.EVT_MENU, self._handleSelectAllAxes, id=self._allId) + bind(self, wx.EVT_MENU, self._handleInvertAxesSelected, id=self._invertId) def Destroy(self): self._menu.Destroy() @@ -1546,11 +1512,7 @@ self._axisId.append(menuId) self._menu.Append(menuId, "Axis %d" % i, "Select axis %d" % i, True) self._menu.Check(menuId, True) - - if wx.VERSION_STRING >= '2.5': - self.Bind(wx.EVT_MENU, self._onMenuItemSelected, id=menuId) - else: - wx.EVT_MENU(self, menuId, self._onMenuItemSelected) + bind(self, wx.EVT_MENU, self._onMenuItemSelected, id=menuId) self._toolbar.set_active(range(len(self._axisId))) def getActiveAxes(self): @@ -1645,22 +1607,13 @@ self.AddSimpleTool(_NTB2_SAVE, _load_bitmap('filesave.png'), 'Save', 'Save plot contents to file') - if wx.VERSION_STRING >= '2.5': - self.Bind(wx.EVT_TOOL, self.home, id=_NTB2_HOME) - self.Bind(wx.EVT_TOOL, self.forward, id=self._NTB2_FORWARD) - self.Bind(wx.EVT_TOOL, self.back, id=self._NTB2_BACK) - self.Bind(wx.EVT_TOOL, self.zoom, id=self._NTB2_ZOOM) - self.Bind(wx.EVT_TOOL, self.pan, id=self._NTB2_PAN) - self.Bind(wx.EVT_TOOL, self.configure_subplot, id=_NTB2_SUBPLOT) - self.Bind(wx.EVT_TOOL, self.save, id=_NTB2_SAVE) - else: - wx.EVT_TOOL(self, _NTB2_HOME, self.home) - wx.EVT_TOOL(self, self._NTB2_FORWARD, self.forward) - wx.EVT_TOOL(self, self._NTB2_BACK, self.back) - wx.EVT_TOOL(self, self._NTB2_ZOOM, self.zoom) - wx.EVT_TOOL(self, self._NTB2_PAN, self.pan) - wx.EVT_TOOL(self, _NTB2_SUBPLOT, self.configure_subplot) - wx.EVT_TOOL(self, _NTB2_SAVE, self.save) + bind(self, wx.EVT_TOOL, self.home, id=_NTB2_HOME) + bind(self, wx.EVT_TOOL, self.forward, id=self._NTB2_FORWARD) + bind(self, wx.EVT_TOOL, self.back, id=self._NTB2_BACK) + bind(self, wx.EVT_TOOL, self.zoom, id=self._NTB2_ZOOM) + bind(self, wx.EVT_TOOL, self.pan, id=self._NTB2_PAN) + bind(self, wx.EVT_TOOL, self.configure_subplot, id=_NTB2_SUBPLOT) + bind(self, wx.EVT_TOOL, self.save, id=_NTB2_SAVE) self.Realize() @@ -1859,34 +1812,19 @@ 'Save', 'Save plot contents as images') self.AddSeparator() - if wx.VERSION_STRING >= '2.5': - self.Bind(wx.EVT_TOOL, self._onLeftScroll, id=_NTB_X_PAN_LEFT) - self.Bind(wx.EVT_TOOL, self._onRightScroll, id=_NTB_X_PAN_RIGHT) - self.Bind(wx.EVT_TOOL, self._onXZoomIn, id=_NTB_X_ZOOMIN) - self.Bind(wx.EVT_TOOL, self._onXZoomOut, id=_NTB_X_ZOOMOUT) - self.Bind(wx.EVT_TOOL, self._onUpScroll, id=_NTB_Y_PAN_UP) - self.Bind(wx.EVT_TOOL, self._onDownScroll, id=_NTB_Y_PAN_DOWN) - self.Bind(wx.EVT_TOOL, self._onYZoomIn, id=_NTB_Y_ZOOMIN) - self.Bind(wx.EVT_TOOL, self._onYZoomOut, id=_NTB_Y_ZOOMOUT) - self.Bind(wx.EVT_TOOL, self._onSave, id=_NTB_SAVE) - self.Bind(wx.EVT_TOOL_ENTER, self._onEnterTool, id=self.GetId()) - if can_kill: - self.Bind(wx.EVT_TOOL, self._onClose, id=_NTB_CLOSE) - self.Bind(wx.EVT_MOUSEWHEEL, self._onMouseWheel) - else: - wx.EVT_TOOL(self, _NTB_X_PAN_LEFT, self._onLeftScroll) - wx.EVT_TOOL(self, _NTB_X_PAN_RIGHT, self._onRightScroll) - wx.EVT_TOOL(self, _NTB_X_ZOOMIN, self._onXZoomIn) - wx.EVT_TOOL(self, _NTB_X_ZOOMOUT, self._onXZoomOut) - wx.EVT_TOOL(self, _NTB_Y_PAN_UP, self._onUpScroll) - wx.EVT_TOOL(self, _NTB_Y_PAN_DOWN, self._onDownScroll) - wx.EVT_TOOL(self, _NTB_Y_ZOOMIN, self._onYZoomIn) - wx.EVT_TOOL(self, _NTB_Y_ZOOMOUT, self._onYZoomOut) - wx.EVT_TOOL(self, _NTB_SAVE, self._onSave) - wx.EVT_TOOL_ENTER(self, self.GetId(), self._onEnterTool) - if can_kill: - wx.EVT_TOOL(self, _NTB_CLOSE, self._onClose) - wx.EVT_MOUSEWHEEL(self, self._onMouseWheel) + bind(self, wx.EVT_TOOL, self._onLeftScroll, id=_NTB_X_PAN_LEFT) + bind(self, wx.EVT_TOOL, self._onRightScroll, id=_NTB_X_PAN_RIGHT) + bind(self, wx.EVT_TOOL, self._onXZoomIn, id=_NTB_X_ZOOMIN) + bind(self, wx.EVT_TOOL, self._onXZoomOut, id=_NTB_X_ZOOMOUT) + bind(self, wx.EVT_TOOL, self._onUpScroll, id=_NTB_Y_PAN_UP) + bind(self, wx.EVT_TOOL, self._onDownScroll, id=_NTB_Y_PAN_DOWN) + bind(self, wx.EVT_TOOL, self._onYZoomIn, id=_NTB_Y_ZOOMIN) + bind(self, wx.EVT_TOOL, self._onYZoomOut, id=_NTB_Y_ZOOMOUT) + bind(self, wx.EVT_TOOL, self._onSave, id=_NTB_SAVE) + bind(self, wx.EVT_TOOL_ENTER, self._onEnterTool, id=self.GetId()) + if can_kill: + bind(self, wx.EVT_TOOL, self._onClose, id=_NTB_CLOSE) + bind(self, wx.EVT_MOUSEWHEEL, self._onMouseWheel) def set_active(self, ind): """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pki...@us...> - 2008-07-25 19:52:13
|
Revision: 5876 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5876&view=rev Author: pkienzle Date: 2008-07-25 19:52:11 +0000 (Fri, 25 Jul 2008) Log Message: ----------- wx backend: implement draw_idle 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-25 17:38:06 UTC (rev 5875) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-07-25 19:52:11 UTC (rev 5876) @@ -719,12 +719,20 @@ 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() + # Create an timer for handling draw_idle requests + # If there are events pending when the timer is + # complete, reset the timer and continue. The + # alternative approach, binding to wx.EVT_IDLE, + # doesn't behave as nicely. + self.idletimer = wx.CallLater(1,self._onDrawIdle) + def Destroy(self, *args, **kwargs): wx.Panel.Destroy(self, *args, **kwargs) @@ -880,8 +888,18 @@ def draw_idle(self, *args, **kwargs): - pass + """ + Delay rendering until the GUI is idle. + """ + DEBUG_MSG("draw_idle()", 1, self) + self.idletimer.Restart(50, *args, **kwargs) # Delay by 50 ms + def _onDrawIdle(self, *args, **kwargs): + if False and wx.GetApp().Pending(): + self.idletimer.Restart(5, *args, **kwargs) + else: + self.draw(*args, **kwargs) + def draw(self, repaint=True): """ Render the figure using RendererWx instance renderer, or using a @@ -960,14 +978,16 @@ redraw the image. """ DEBUG_MSG("gui_repaint()", 1, self) - if drawDC is None: - drawDC=wx.ClientDC(self) + if self.IsShownOnScreen(): - drawDC.BeginDrawing() - drawDC.DrawBitmap(self.bitmap, 0, 0) - drawDC.EndDrawing() - #wx.GetApp().Yield() + if drawDC is None: + drawDC=wx.ClientDC(self) + drawDC.BeginDrawing() + drawDC.DrawBitmap(self.bitmap, 0, 0) + drawDC.EndDrawing() + #wx.GetApp().Yield() + filetypes = FigureCanvasBase.filetypes.copy() filetypes['bmp'] = 'Windows bitmap' filetypes['jpeg'] = 'JPEG' @@ -1031,6 +1051,10 @@ # Restore everything to normal self.bitmap = origBitmap + # Note: draw is required here since bits of state about the + # last renderer are strewn about the artist draw methods. Do + # not remove the draw without first verifying that these have + # been cleaned up. self.draw() self.Refresh() @@ -1089,7 +1113,7 @@ self.figure.set_size_inches(winch, hinch) if self._isRealized: - self.draw() + self.draw_idle() evt.Skip() def _get_key(self, evt): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2008-07-27 17:18:33
|
Revision: 5903 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5903&view=rev Author: efiring Date: 2008-07-27 17:18:30 +0000 (Sun, 27 Jul 2008) Log Message: ----------- Change backend_wx function to backwards-compatible alias 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 05:13:23 UTC (rev 5902) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-07-27 17:18:30 UTC (rev 5903) @@ -731,7 +731,10 @@ # complete, reset the timer and continue. The # alternative approach, binding to wx.EVT_IDLE, # doesn't behave as nicely. - self.idletimer = wx.CallLater(1,self._onDrawIdle) + #self.idletimer = wx.CallLater(1,self._onDrawIdle) + self.idletimer = wx.FutureCall(1,self._onDrawIdle) + # FutureCall is a backwards-compatible alias; + # CallLater became available in 2.7.1.1. def Destroy(self, *args, **kwargs): wx.Panel.Destroy(self, *args, **kwargs) @@ -1051,7 +1054,7 @@ # Restore everything to normal self.bitmap = origBitmap - # Note: draw is required here since bits of state about the + # Note: draw is required here since bits of state about the # last renderer are strewn about the artist draw methods. Do # not remove the draw without first verifying that these have # been cleaned up. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pki...@us...> - 2008-07-27 20:42:15
|
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. |
From: <jd...@us...> - 2008-07-29 18:01:19
|
Revision: 5923 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5923&view=rev Author: jdh2358 Date: 2008-07-29 18:01:16 +0000 (Tue, 29 Jul 2008) Log Message: ----------- special case contains test for degenerate rectangle 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-29 17:47:50 UTC (rev 5922) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-07-29 18:01:16 UTC (rev 5923) @@ -696,6 +696,10 @@ except AttributeError: self.SetInitialSize = getattr(self, 'SetBestFittingSize', do_nothing) + + if not hasattr(self,'IsShownOnScreen'): + self.IsShownOnScreen = self.IsVisible + # Create the drawing bitmap self.bitmap =wx.EmptyBitmap(w, h) DEBUG_MSG("__init__() - bitmap w:%d h:%d" % (w,h), 2, self) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-07-29 21:42:39
|
Revision: 5926 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5926&view=rev Author: jdh2358 Date: 2008-07-29 21:42:37 +0000 (Tue, 29 Jul 2008) Log Message: ----------- another attempt at portable isvisible for wx 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-29 19:59:43 UTC (rev 5925) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-07-29 21:42:37 UTC (rev 5926) @@ -698,8 +698,9 @@ if not hasattr(self,'IsShownOnScreen'): - self.IsShownOnScreen = self.IsVisible + self.IsShownOnScreen = getattr(self, 'IsVisible', lambda self: True) + # Create the drawing bitmap self.bitmap =wx.EmptyBitmap(w, h) DEBUG_MSG("__init__() - bitmap w:%d h:%d" % (w,h), 2, self) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-07-30 17:30:22
|
Revision: 5932 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5932&view=rev Author: jdh2358 Date: 2008-07-30 17:30:19 +0000 (Wed, 30 Jul 2008) Log Message: ----------- another try at wx 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-30 16:32:50 UTC (rev 5931) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-07-30 17:30:19 UTC (rev 5932) @@ -698,7 +698,7 @@ if not hasattr(self,'IsShownOnScreen'): - self.IsShownOnScreen = getattr(self, 'IsVisible', lambda self: True) + self.IsShownOnScreen = getattr(self, 'IsVisible', lambda *args: True) # Create the drawing bitmap This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-07-31 14:10:24
|
Revision: 5935 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5935&view=rev Author: mdboom Date: 2008-07-31 14:10:18 +0000 (Thu, 31 Jul 2008) Log Message: ----------- Warn when using Wx backend with wxPython < 2.8 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-31 13:50:58 UTC (rev 5934) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-07-31 14:10:18 UTC (rev 5935) @@ -249,6 +249,8 @@ Initialise a wxWindows renderer instance. """ DEBUG_MSG("__init__()", 1, self) + if wx.VERSION_STRING < "2.8": + raise RuntimeError("matplotlib no longer supports wxPython < 2.8 for the Wx backend.\nYou may, however, use the WxAgg backend.") self.width = bitmap.GetWidth() self.height = bitmap.GetHeight() self.bitmap = bitmap This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2008-09-26 21:52:45
|
Revision: 6123 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6123&view=rev Author: efiring Date: 2008-09-26 21:52:34 +0000 (Fri, 26 Sep 2008) Log Message: ----------- fixed bug in PrintoutWX--thanks to Ziwen Fu 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-09-25 17:16:30 UTC (rev 6122) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-09-26 21:52:34 UTC (rev 6123) @@ -2109,7 +2109,7 @@ # restore original figure resolution self.canvas.figure.set_facecolor(bgcolor) - self.canvas.figure.dpi.set(fig_dpi) + self.canvas.figure.dpi = fig_dpi self.canvas.draw() return True #> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-10-20 16:20:03
|
Revision: 6284 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6284&view=rev Author: jdh2358 Date: 2008-10-20 16:19:51 +0000 (Mon, 20 Oct 2008) Log Message: ----------- Applied Lee's backend wx patch 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-10-20 14:16:05 UTC (rev 6283) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-10-20 16:19:51 UTC (rev 6284) @@ -96,6 +96,7 @@ import sys, os, os.path, math, StringIO, weakref, warnings +import numpy as npy # Debugging settings here... # Debug level set here. If the debug level is less than 5, information @@ -333,6 +334,23 @@ gfx_ctx.StrokePath(wxpath) gc.unselect() + def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None): + if bbox != None: + l,b,w,h = bbox.bounds + else: + l=0 + b=0, + w=self.width + h=self.height + rows, cols, image_str = im.as_rgba_str() + image_array = npy.fromstring(image_str, npy.uint8) + image_array.shape = rows, cols, 4 + bitmap = wx.BitmapFromBufferRGBA(cols,rows,image_array) + gc = self.get_gc() + gc.select() + gc.gfx_ctx.DrawBitmap(bitmap,int(l),int(b),int(w),int(h)) + gc.unselect() + def draw_text(self, gc, x, y, s, prop, angle, ismath): """ Render the matplotlib.text.Text instance @@ -482,7 +500,7 @@ """ if sys.platform=='win32': - self.SelectObject(self.bitmap) + self.dc.SelectObject(self.bitmap) self.IsSelected = True def unselect(self): @@ -490,7 +508,7 @@ Select a Null bitmasp into this wxDC instance """ if sys.platform=='win32': - self.SelectObject(wx.NullBitmap) + self.dc.SelectObject(wx.NullBitmap) self.IsSelected = False def set_foreground(self, fg, isRGB=None): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-12-03 18:38:07
|
Revision: 6484 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6484&view=rev Author: jdh2358 Date: 2008-12-03 18:38:03 +0000 (Wed, 03 Dec 2008) Log Message: ----------- committed Gregor's enter notify update for backend wx 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-12-03 15:33:53 UTC (rev 6483) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-12-03 18:38:03 UTC (rev 6484) @@ -743,6 +743,7 @@ bind(self, wx.EVT_LEFT_UP, self._onLeftButtonUp) bind(self, wx.EVT_MOTION, self._onMotion) bind(self, wx.EVT_LEAVE_WINDOW, self._onLeave) + bind(self, wx.EVT_ENTER_WINDOW, self._onEnter) bind(self, wx.EVT_IDLE, self._onIdle) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) @@ -1268,7 +1269,11 @@ evt.Skip() FigureCanvasBase.leave_notify_event(self, guiEvent = evt) + def _onEnter(self, evt): + """Mouse has entered the window.""" + FigureCanvasBase.enter_notify_event(self, guiEvent = evt) + ######################################################################## # # The following functions and classes are for pylab compatibility This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2009-07-10 19:41:21
|
Revision: 7251 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7251&view=rev Author: efiring Date: 2009-07-10 19:41:12 +0000 (Fri, 10 Jul 2009) Log Message: ----------- Allow for broken wxversion in backend_wx 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 2009-07-08 21:15:46 UTC (rev 7250) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2009-07-10 19:41:12 UTC (rev 7251) @@ -115,10 +115,15 @@ except ImportError: raise ImportError(missingwx) -try: - wxversion.ensureMinimal('2.8') -except wxversion.AlreadyImportedError: - pass +# Some early versions of wxversion lack AlreadyImportedError. +if hasattr(wxversion, 'AlreadyImportedError'): + try: + wxversion.ensureMinimal('2.8') + except wxversion.AlreadyImportedError: + pass +else: + warnings.warn( + "Update your wxversion.py to one including AlreadyImportedError") try: import wx @@ -126,6 +131,12 @@ except ImportError: raise ImportError(missingwx) +# Extra version check in case wxversion is broken: +major, minor = [int(n) for n in backend_version.split('.')[:2]] +if major < 2 or (major < 3 and minor < 8): + raise ImportError(missingwx) + + #!!! this is the call that is causing the exception swallowing !!! #wx.InitAllImageHandlers() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2009-07-10 21:32:39
|
Revision: 7252 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7252&view=rev Author: efiring Date: 2009-07-10 21:32:27 +0000 (Fri, 10 Jul 2009) Log Message: ----------- Another fix for wxversion problem (thanks, Gael Varoquaux) 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 2009-07-10 19:41:12 UTC (rev 7251) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2009-07-10 21:32:27 UTC (rev 7252) @@ -124,6 +124,10 @@ else: warnings.warn( "Update your wxversion.py to one including AlreadyImportedError") + try: + wxversion.ensureMinimal('2.8') + except wxversion.VersionError: + pass try: import wx This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2009-07-11 18:06:59
|
Revision: 7256 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7256&view=rev Author: efiring Date: 2009-07-11 18:06:54 +0000 (Sat, 11 Jul 2009) Log Message: ----------- Yet another iteration on the version checking in backend_wx 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 2009-07-11 16:52:44 UTC (rev 7255) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2009-07-11 18:06:54 UTC (rev 7256) @@ -116,28 +116,31 @@ raise ImportError(missingwx) # Some early versions of wxversion lack AlreadyImportedError. -if hasattr(wxversion, 'AlreadyImportedError'): - try: - wxversion.ensureMinimal('2.8') - except wxversion.AlreadyImportedError: - pass -else: - warnings.warn( - "Update your wxversion.py to one including AlreadyImportedError") - try: - wxversion.ensureMinimal('2.8') - except wxversion.VersionError: - pass +# It was added around 2.8.4? +try: + _wx_ensure_failed = wxversion.AlreadyImportedError +except AttributeError: + _wx_ensure_failed = wxversion.VersionError try: + wxversion.ensureMinimal('2.8') +except _wx_ensure_failed: + pass +# We don't really want to pass in case of VersionError, but when +# AlreadyImportedError is not available, we have to. + +try: import wx backend_version = wx.VERSION_STRING except ImportError: raise ImportError(missingwx) -# Extra version check in case wxversion is broken: +# Extra version check in case wxversion lacks AlreadyImportedError; +# then VersionError might have been raised and ignored when +# there really *is* a problem with the version. major, minor = [int(n) for n in backend_version.split('.')[:2]] if major < 2 or (major < 3 and minor < 8): + print " wxPython version %s was imported." % backend_version raise ImportError(missingwx) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ry...@us...> - 2010-04-20 19:42:34
|
Revision: 8253 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8253&view=rev Author: ryanmay Date: 2010-04-20 19:42:29 +0000 (Tue, 20 Apr 2010) Log Message: ----------- Add TimerWx and new_timer() method. 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 2010-04-20 19:42:05 UTC (rev 8252) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2010-04-20 19:42:29 UTC (rev 8253) @@ -190,7 +190,7 @@ from matplotlib import verbose from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\ FigureCanvasBase, FigureManagerBase, NavigationToolbar2, \ - cursors + cursors, TimerBase from matplotlib._pylab_helpers import Gcf from matplotlib.artist import Artist from matplotlib.cbook import exception_to_str, is_string_like, is_writable_file_like @@ -226,6 +226,52 @@ msg = '\n'.join(map(str, msg)) return msg + +class TimerWx(TimerBase): + ''' + Subclass of :class:`backend_bases.TimerBase` that uses WxTimer events. + + Attributes: + * interval: The time between timer events in milliseconds. Default + is 1000 ms. + * single_shot: Boolean flag indicating whether this timer should + operate as single shot (run once and then stop). Defaults to False. + * callbacks: Stores list of (func, args) tuples that will be called + upon timer events. This list can be manipulated directly, or the + functions add_callback and remove_callback can be used. + ''' + def __init__(self, parent): + import wx + TimerBase.__init__(self) + + # Create a new timer and connect the timer event to our handler. + # For WX, the events have to use a widget for binding. + self.parent = parent + self._timer = wx.Timer(self.parent, wx.NewId()) + self.parent.Bind(wx.EVT_TIMER, self._on_timer, self._timer) + + # Unbinding causes Wx to stop for some reason. Disabling for now. +# def __del__(self): +# import wx +# TimerBase.__del__(self) +# self.parent.Bind(wx.EVT_TIMER, None, self._timer) + + def _timer_start(self): + self._timer.Start(self._interval, self._single) + + def _timer_stop(self): + self._timer.Stop() + + def _timer_set_interval(self): + self._timer_start() + + def _timer_set_single_shot(self): + self._timer.start() + + def _on_timer(self, *args): + TimerBase._on_timer(self) + + class RendererWx(RendererBase): """ The renderer handles all the drawing primitives using a graphics @@ -938,7 +984,6 @@ printout.Destroy() self.gui_repaint() - def draw_idle(self): """ Delay rendering until the GUI is idle. @@ -978,6 +1023,14 @@ self._isDrawn = True self.gui_repaint(drawDC=drawDC) + def new_timer(self): + """ + Creates a new backend-specific subclass of + :class:`backend_bases.TimerBase`. This is useful for getting periodic + events through the backend's native event loop. + """ + return TimerWx(self) + def flush_events(self): wx.Yield() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ry...@us...> - 2010-04-20 19:59:29
|
Revision: 8256 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8256&view=rev Author: ryanmay Date: 2010-04-20 19:59:23 +0000 (Tue, 20 Apr 2010) Log Message: ----------- Remove extra import in timer. 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 2010-04-20 19:58:10 UTC (rev 8255) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2010-04-20 19:59:23 UTC (rev 8256) @@ -241,7 +241,6 @@ functions add_callback and remove_callback can be used. ''' def __init__(self, parent): - import wx TimerBase.__init__(self) # Create a new timer and connect the timer event to our handler. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-06-04 18:47:54
|
Revision: 8377 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8377&view=rev Author: efiring Date: 2010-06-04 18:47:48 +0000 (Fri, 04 Jun 2010) Log Message: ----------- [2941338] backend_wx: disconnect drag before destroying frame 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 2010-06-04 15:40:44 UTC (rev 8376) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2010-06-04 18:47:48 UTC (rev 8377) @@ -230,7 +230,7 @@ class TimerWx(TimerBase): ''' Subclass of :class:`backend_bases.TimerBase` that uses WxTimer events. - + Attributes: * interval: The time between timer events in milliseconds. Default is 1000 ms. @@ -1027,9 +1027,9 @@ Creates a new backend-specific subclass of :class:`backend_bases.Timer`. This is useful for getting periodic events through the backend's native event loop. Implemented only for backends with GUIs. - + optional arguments: - + *interval* Timer interval in milliseconds *callbacks* @@ -1546,6 +1546,8 @@ return self.toolbar def Destroy(self, *args, **kwargs): + self.canvas.mpl_disconnect(self.toolbar._idDrag) + # Rationale for line above: see issue 2941338. wx.Frame.Destroy(self, *args, **kwargs) if self.toolbar is not None: self.toolbar.Destroy() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-06-08 21:57:22
|
Revision: 8397 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8397&view=rev Author: efiring Date: 2010-06-08 21:57:14 +0000 (Tue, 08 Jun 2010) Log Message: ----------- backend_wx: modernize show; multiple calls to show work now 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 2010-06-07 23:39:24 UTC (rev 8396) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2010-06-08 21:57:14 UTC (rev 8397) @@ -1423,32 +1423,22 @@ def show(): """ - Current implementation assumes that matplotlib is executed in a PyCrust - shell. It appears to be possible to execute wxPython applications from - within a PyCrust without having to ensure that wxPython has been created - in a secondary thread (e.g. SciPy gui_thread). - - Unfortunately, gui_thread seems to introduce a number of further - dependencies on SciPy modules, which I do not wish to introduce - into the backend at this point. If there is a need I will look - into this in a later release. + Show all the figures and enter the wx main loop. + This should be the last line of your script. """ DEBUG_MSG("show()", 3, None) for figwin in Gcf.get_all_fig_managers(): figwin.frame.Show() - if show._needmain and not matplotlib.is_interactive(): - # start the wxPython gui event if there is not already one running + needmain = not wx.App.IsMainLoopRunning() + if needmain and len(Gcf.get_all_fig_managers())>0: wxapp = wx.GetApp() if wxapp is not None: - # wxPython 2.4 has no wx.App.IsMainLoopRunning() method - imlr = getattr(wxapp, 'IsMainLoopRunning', lambda: False) - if not imlr(): - wxapp.MainLoop() - show._needmain = False -show._needmain = True + wxapp.MainLoop() + # start the wxPython gui event if there is not already one running + def new_figure_manager(num, *args, **kwargs): """ Create a new figure manager instance This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-06-11 07:24:02
|
Revision: 8411 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8411&view=rev Author: efiring Date: 2010-06-11 07:23:54 +0000 (Fri, 11 Jun 2010) Log Message: ----------- backend_wx: remove ancient comment string 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 2010-06-10 18:43:34 UTC (rev 8410) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2010-06-11 07:23:54 UTC (rev 8411) @@ -17,81 +17,7 @@ should be included with this source code. """ -""" -KNOWN BUGS - - - Mousewheel (on Windows) only works after menu button has been pressed - at least once - - Mousewheel on Linux (wxGTK linked against GTK 1.2) does not work at all - - Vertical text renders horizontally if you use a non TrueType font - on Windows. This is a known wxPython issue. Work-around is to ensure - that you use a TrueType font. - - Pcolor demo puts chart slightly outside bounding box (approx 1-2 pixels - to the bottom left) - - Outputting to bitmap more than 300dpi results in some text being incorrectly - scaled. Seems to be a wxPython bug on Windows or font point sizes > 60, as - font size is correctly calculated. - - Performance poorer than for previous direct rendering version - - TIFF output not supported on wxGTK. This is a wxGTK issue - - Text is not anti-aliased on wxGTK. This is probably a platform - configuration issue. - - If a second call is made to show(), no figure is generated (#866965) -Not implemented: - - Printing - -Fixed this release: - - Bug #866967: Interactive operation issues fixed [JDH] - - Bug #866969: Dynamic update does not function with backend_wx [JOD] - -Examples which work on this release: - --------------------------------------------------------------- - | Windows 2000 | Linux | - | wxPython 2.3.3 | wxPython 2.4.2.4 | - --------------------------------------------------------------| - - alignment_test.py | TBE | OK | - - arctest.py | TBE | (3) | - - axes_demo.py | OK | OK | - - axes_props.py | OK | OK | - - bar_stacked.py | TBE | OK | - - barchart_demo.py | OK | OK | - - color_demo.py | OK | OK | - - csd_demo.py | OK | OK | - - dynamic_demo.py | N/A | N/A | - - dynamic_demo_wx.py | TBE | OK | - - embedding_in_gtk.py | N/A | N/A | - - embedding_in_wx.py | OK | OK | - - errorbar_demo.py | OK | OK | - - figtext.py | OK | OK | - - histogram_demo.py | OK | OK | - - interactive.py | N/A (2) | N/A (2) | - - interactive2.py | N/A (2) | N/A (2) | - - legend_demo.py | OK | OK | - - legend_demo2.py | OK | OK | - - line_styles.py | OK | OK | - - log_demo.py | OK | OK | - - logo.py | OK | OK | - - mpl_with_glade.py | N/A (2) | N/A (2) | - - mri_demo.py | OK | OK | - - mri_demo_with_eeg.py | OK | OK | - - multiple_figs_demo.py | OK | OK | - - pcolor_demo.py | OK | OK | - - psd_demo.py | OK | OK | - - scatter_demo.py | OK | OK | - - scatter_demo2.py | OK | OK | - - simple_plot.py | OK | OK | - - stock_demo.py | OK | OK | - - subplot_demo.py | OK | OK | - - system_monitor.py | N/A (2) | N/A (2) | - - text_handles.py | OK | OK | - - text_themes.py | OK | OK | - - vline_demo.py | OK | OK | - --------------------------------------------------------------- - - (2) - Script uses GTK-specific features - cannot not run, - but wxPython equivalent should be written. - (3) - Clipping seems to be broken. -""" - cvs_id = '$Id$' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-06-20 01:34:39
|
Revision: 8442 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8442&view=rev Author: efiring Date: 2010-06-20 01:34:30 +0000 (Sun, 20 Jun 2010) Log Message: ----------- [2564093] backend_wx: don't initialize printer by default; deprecate Printer* 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 2010-06-19 23:46:47 UTC (rev 8441) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2010-06-20 01:34:30 UTC (rev 8442) @@ -754,7 +754,11 @@ self.macros = {} # dict from wx id to seq of macros - self.Printer_Init() + # printer attributes and methods deprecated, 2010/06/19 + self._printerData = None + self._printerPageData = None + self.printer_width = 5.5 + self.printer_margin = 0.5 def Destroy(self, *args, **kwargs): wx.Panel.Destroy(self, *args, **kwargs) @@ -769,7 +773,12 @@ wx.TheClipboard.Close() def Printer_Init(self): - """initialize printer settings using wx methods""" + """ + initialize printer settings using wx methods + + Deprecated. + """ + warnings.warn("Printer* methods will be removed", DeprecationWarning) self.printerData = wx.PrintData() self.printerData.SetPaperId(wx.PAPER_LETTER) self.printerData.SetPrintMode(wx.PRINT_MODE_PRINTER) @@ -781,14 +790,37 @@ self.printer_width = 5.5 self.printer_margin= 0.5 + def _get_printerData(self): + if self._printerData is None: + warnings.warn("Printer* methods will be removed", DeprecationWarning) + self._printerData = wx.PrintData() + self._printerData.SetPaperId(wx.PAPER_LETTER) + self._printerData.SetPrintMode(wx.PRINT_MODE_PRINTER) + return self._printerData + printerData = property(_get_printerData) + + def _get_printerPageData(self): + if self._printerPageData is None: + warnings.warn("Printer* methods will be removed", DeprecationWarning) + self._printerPageData= wx.PageSetupDialogData() + self._printerPageData.SetMarginBottomRight((25,25)) + self._printerPageData.SetMarginTopLeft((25,25)) + self._printerPageData.SetPrintData(self.printerData) + return self._printerPageData + printerPageData = property(_get_printerPageData) + def Printer_Setup(self, event=None): - """set up figure for printing. The standard wx Printer + """ + set up figure for printing. The standard wx Printer Setup Dialog seems to die easily. Therefore, this setup - simply asks for image width and margin for printing. """ + simply asks for image width and margin for printing. + Deprecated. + """ dmsg = """Width of output figure in inches. The current aspect ratio will be kept.""" + warnings.warn("Printer* methods will be removed", DeprecationWarning) dlg = wx.Dialog(self, -1, 'Page Setup for Printing' , (-1,-1)) df = dlg.GetFont() df.SetWeight(wx.NORMAL) @@ -844,9 +876,14 @@ return def Printer_Setup2(self, event=None): - """set up figure for printing. Using the standard wx Printer - Setup Dialog. """ + """ + set up figure for printing. Using the standard wx Printer + Setup Dialog. + Deprecated. + """ + + warnings.warn("Printer* methods will be removed", DeprecationWarning) if hasattr(self, 'printerData'): data = wx.PageSetupDialogData() data.SetPrintData(self.printerData) @@ -865,7 +902,12 @@ dlg.Destroy() def Printer_Preview(self, event=None): - """ generate Print Preview with wx Print mechanism""" + """ + generate Print Preview with wx Print mechanism + + Deprecated. + """ + warnings.warn("Printer* methods will be removed", DeprecationWarning) po1 = PrintoutWx(self, width=self.printer_width, margin=self.printer_margin) po2 = PrintoutWx(self, width=self.printer_width, @@ -886,7 +928,12 @@ self.gui_repaint() def Printer_Print(self, event=None): - """ Print figure using wx Print mechanism""" + """ + Print figure using wx Print mechanism + + Deprecated. + """ + warnings.warn("Printer* methods will be removed", DeprecationWarning) pdd = wx.PrintDialogData() # SetPrintData for 2.4 combatibility pdd.SetPrintData(self.printerData) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |