@@ -61,7 +61,7 @@ def DEBUG_MSG(string, lvl=3, o=None):
6161 # Jeremy, often times the commented line won't print but the
6262 # one below does. I think WX is redefining stderr, damned
6363 # beast
64- #print >>sys.stderr, "%s- %s in %s" % (_DEBUG_lvls[lvl], string, cls)
64+ # print >>sys.stderr, "%s- %s in %s" % (_DEBUG_lvls[lvl], string, cls)
6565 print ("%s- %s in %s" % (_DEBUG_lvls [lvl ], string , cls ))
6666
6767
@@ -82,10 +82,6 @@ class fake_stderr(object):
8282 def write (self , msg ):
8383 print ("Stderr: %s\n \r " % msg )
8484
85- #if _DEBUG < 5:
86- #sys.excepthook = debug_on_error
87- #WxLogger =wx.LogStderr()
88- #sys.stderr = fake_stderr
8985
9086# the True dots per inch on the screen; should be display dependent
9187# see
@@ -410,7 +406,7 @@ class GraphicsContextWx(GraphicsContextBase):
410406
411407 def __init__ (self , bitmap , renderer ):
412408 GraphicsContextBase .__init__ (self )
413- #assert self.Ok(), "wxMemoryDC not OK to use"
409+ # assert self.Ok(), "wxMemoryDC not OK to use"
414410 DEBUG_MSG ("__init__()" , 1 , self )
415411 DEBUG_MSG ("__init__() 2: %s" % bitmap , 1 , self )
416412
@@ -1201,10 +1197,10 @@ def __init__(self, num, fig):
12011197 # This is not currently working on Linux and is untested elsewhere.
12021198 # icon_path = os.path.join(matplotlib.rcParams['datapath'],
12031199 # 'images', 'matplotlib.png')
1204- #icon = wx.IconFromBitmap(wx.Bitmap(icon_path))
1205- # for xpm type icons try:
1206- #icon = wx.Icon(icon_path, wx.BITMAP_TYPE_XPM)
1207- # self.SetIcon(icon)
1200+ # icon = wx.IconFromBitmap(wx.Bitmap(icon_path))
1201+ # for xpm type icons try:
1202+ # icon = wx.Icon(icon_path, wx.BITMAP_TYPE_XPM)
1203+ # self.SetIcon(icon)
12081204
12091205 self .figmgr = FigureManagerWx (self .canvas , num , self )
12101206
@@ -1308,7 +1304,8 @@ def resize(self, width, height):
13081304# Identifiers for toolbar controls - images_wx contains bitmaps for the images
13091305# used in the controls. wxWindows does not provide any stock images, so I've
13101306# 'stolen' those from GTK2, and transformed them into the appropriate format.
1311- #import images_wx
1307+ # import images_wx
1308+
13121309
13131310_NTB_AXISMENU = wx .NewId ()
13141311_NTB_AXISMENU_BUTTON = wx .NewId ()
@@ -1320,7 +1317,7 @@ def resize(self, width, height):
13201317_NTB_Y_PAN_DOWN = wx .NewId ()
13211318_NTB_Y_ZOOMIN = wx .NewId ()
13221319_NTB_Y_ZOOMOUT = wx .NewId ()
1323- #_NTB_SUBPLOT =wx.NewId()
1320+ # _NTB_SUBPLOT =wx.NewId()
13241321_NTB_SAVE = wx .NewId ()
13251322_NTB_CLOSE = wx .NewId ()
13261323
@@ -1513,8 +1510,8 @@ def _init_toolbar(self):
15131510 continue
15141511 self .wx_ids [text ] = wx .NewId ()
15151512 wxc ._AddTool (self , self .wx_ids , text ,
1516- _load_bitmap (image_file + '.png' ),
1517- tooltip_text )
1513+ _load_bitmap (image_file + '.png' ),
1514+ tooltip_text )
15181515
15191516 self .Bind (wx .EVT_TOOL , getattr (self , callback ),
15201517 id = self .wx_ids [text ])
@@ -1584,12 +1581,6 @@ def set_cursor(self, cursor):
15841581 self .canvas .SetCursor (cursor )
15851582 self .canvas .Update ()
15861583
1587- def release (self , event ):
1588- try :
1589- del self .lastrect
1590- except AttributeError :
1591- pass
1592-
15931584 @cbook .deprecated ("2.1" , alternative = "canvas.draw_idle" )
15941585 def dynamic_update (self ):
15951586 d = self ._idle
@@ -1707,7 +1698,7 @@ def __init__(self, parent):
17071698 wx .StatusBar .__init__ (self , parent , - 1 )
17081699 self .SetFieldsCount (2 )
17091700 self .SetStatusText ("None" , 1 )
1710- #self.SetStatusText("Measurement: None", 2)
1701+ # self.SetStatusText("Measurement: None", 2)
17111702 # self.Reposition()
17121703
17131704 def set_function (self , string ):
@@ -1767,7 +1758,7 @@ def set_cursor(self, cursor):
17671758 self .canvas .Update ()
17681759
17691760
1770- if not 'wxMac' in wx .PlatformInfo :
1761+ if 'wxMac' not in wx .PlatformInfo :
17711762 # on most platforms, use overlay
17721763 class RubberbandWx (backend_tools .RubberbandBase ):
17731764 def __init__ (self , * args , ** kwargs ):
@@ -1813,7 +1804,8 @@ def draw_rubberband(self, x0, y0, x1, y1):
18131804 dc .DrawRectangleRect (rect )
18141805
18151806 def remove_rubberband (self ):
1816- if self .wxoverlay is None : return
1807+ if self .wxoverlay is None :
1808+ return
18171809 self .wxoverlay .Reset ()
18181810 self .wxoverlay = None
18191811
@@ -1831,29 +1823,31 @@ def draw_rubberband(self, x0, y0, x1, y1):
18311823 # this would be required if the Canvas is a ScrolledWindow,
18321824 # which is not the case for now
18331825 # self.PrepareDC(dc)
1834-
1826+
18351827 # delete old rubberband
1836- if self ._rect : self .remove_rubberband (dc )
1837-
1828+ if self ._rect :
1829+ self .remove_rubberband (dc )
1830+
18381831 # draw new rubberband
1839- dc .SetPen (wx .Pen (wx .BLACK , 1 , wx .SOLID ))
1832+ dc .SetPen (wx .Pen (wx .BLACK , 1 , wx .SOLID ))
18401833 dc .SetBrush (wx .TRANSPARENT_BRUSH )
1841- self ._rect = (x0 ,self .canvas ._height - y0 , x1 - x0 , - y1 + y0 )
1834+ self ._rect = (x0 , self .canvas ._height - y0 , x1 - x0 , - y1 + y0 )
18421835 if wxc .is_phoenix :
18431836 dc .DrawRectangle (self ._rect )
18441837 else :
18451838 dc .DrawRectangleRect (self ._rect )
18461839
18471840 def remove_rubberband (self , dc = None ):
1848- if not self ._rect : return
1841+ if not self ._rect :
1842+ return
18491843 if self .canvas .bitmap :
18501844 if dc is None :
18511845 dc = wx .ClientDC (self .canvas )
18521846 dc .DrawBitmap (self .canvas .bitmap , 0 , 0 )
1853- # for testing the method on Windows, use this code instead:
1854- #img = self.canvas.bitmap.ConvertToImage()
1855- #bmp = img.ConvertToBitmap()
1856- #dc.DrawBitmap(bmp, 0, 0)
1847+ # for testing the method on Windows, use this code instead:
1848+ # img = self.canvas.bitmap.ConvertToImage()
1849+ # bmp = img.ConvertToBitmap()
1850+ # dc.DrawBitmap(bmp, 0, 0)
18571851 self ._rect = None
18581852
18591853
@@ -1862,8 +1856,7 @@ def remove_rubberband(self, dc=None):
18621856backend_tools .ToolRubberband = RubberbandWx
18631857
18641858
1865-
1866- #< Additions for printing support: Matt Newville
1859+ # < Additions for printing support: Matt Newville
18671860
18681861class PrintoutWx (wx .Printout ):
18691862 """
@@ -1938,25 +1931,26 @@ def OnPrintPage(self, page):
19381931 # this cute little number avoid API inconsistencies in wx
19391932 try :
19401933 dc .DrawBitmap (self .canvas .bitmap , 0 , 0 )
1941- except :
1934+ except Exception :
19421935 try :
19431936 dc .DrawBitmap (self .canvas .bitmap , (0 , 0 ))
1944- except :
1937+ except Exception :
19451938 pass
19461939
19471940 # restore original figure resolution
19481941 self .canvas .figure .set_facecolor (bgcolor )
19491942 self .canvas .figure .dpi = fig_dpi
19501943 self .canvas .draw ()
19511944 return True
1952- #>
1945+ # >
19531946
19541947########################################################################
19551948#
19561949# Now just provide the standard names that backend.__init__ is expecting
19571950#
19581951########################################################################
19591952
1953+
19601954Toolbar = NavigationToolbar2Wx
19611955
19621956
0 commit comments