1919 NavigationToolbar2 , RendererBase , TimerBase , cursors )
2020from matplotlib .backend_bases import _has_pil
2121
22+ from matplotlib import cbook , rcParams , backend_tools
2223from matplotlib ._pylab_helpers import Gcf
2324from matplotlib .cbook import is_writable_file_like , warn_deprecated
2425from matplotlib .figure import Figure
2526from matplotlib .path import Path
2627from matplotlib .transforms import Affine2D
2728from matplotlib .widgets import SubplotTool
28- from matplotlib import cbook , rcParams , backend_tools
2929
3030import wx
3131
3535# traceback is performed, and pdb activated, for all uncaught exceptions in
3636# this case
3737_DEBUG = 5
38- if _DEBUG < 5 :
39- import traceback
40- import pdb
4138_DEBUG_lvls = {1 : 'Low ' , 2 : 'Med ' , 3 : 'High' , 4 : 'Error' }
4239
4340
4441def DEBUG_MSG (string , lvl = 3 , o = None ):
4542 if lvl >= _DEBUG :
46- cls = o .__class__
47- # Jeremy, often times the commented line won't print but the
48- # one below does. I think WX is redefining stderr, damned
49- # beast
50- # print("%s- %s in %s" % (_DEBUG_lvls[lvl], string, cls),
51- # file=sys.stderr)
52- print ("%s- %s in %s" % (_DEBUG_lvls [lvl ], string , cls ))
43+ print ("%s- %s in %s" % (_DEBUG_lvls [lvl ], string , type (o )))
5344
5445
46+ @cbook .deprecated ("3.0" )
5547def debug_on_error (type , value , tb ):
5648 """Code due to Thomas Heller - published in Python Cookbook (O'Reilley)"""
49+ import pdb
50+ import traceback
5751 traceback .print_exception (type , value , tb )
5852 print ()
59- pdb .pm () # jdh uncomment
53+ pdb .pm ()
6054
6155
56+ @cbook .deprecated ("3.0" )
6257class fake_stderr (object ):
6358 """
6459 Wx does strange things with stderr, as it makes the assumption that
@@ -93,6 +88,7 @@ def error_msg_wx(msg, parent=None):
9388 return None
9489
9590
91+ @cbook .deprecated ("3.0" )
9692def raise_msg_to_str (msg ):
9793 """msg is a return arg from a raise. Join with new lines."""
9894 if not isinstance (msg , str ):
@@ -1104,22 +1100,16 @@ def _print_image(self, filename, filetype, *args, **kwargs):
11041100 image = self .bitmap .ConvertToImage ()
11051101 image .SetOption (wx .IMAGE_OPTION_QUALITY , str (jpeg_quality ))
11061102
1107- # Now that we have rendered into the bitmap, save it
1108- # to the appropriate file type and clean up
1103+ # Now that we have rendered into the bitmap, save it to the appropriate
1104+ # file type and clean up.
11091105 if isinstance (filename , str ):
11101106 if not image .SaveFile (filename , filetype ):
1111- DEBUG_MSG ('print_figure() file save error' , 4 , self )
1112- raise RuntimeError (
1113- 'Could not save figure to %s\n ' %
1114- (filename ))
1107+ raise RuntimeError ('Could not save figure to %s' % filename )
11151108 elif is_writable_file_like (filename ):
11161109 if not isinstance (image , wx .Image ):
11171110 image = image .ConvertToImage ()
11181111 if not image .SaveStream (filename , filetype ):
1119- DEBUG_MSG ('print_figure() file save error' , 4 , self )
1120- raise RuntimeError (
1121- 'Could not save figure to %s\n ' %
1122- (filename ))
1112+ raise RuntimeError ('Could not save figure to %s' % filename )
11231113
11241114 # Restore everything to normal
11251115 self .bitmap = origBitmap
@@ -1286,11 +1276,7 @@ def resize(self, width, height):
12861276 self .canvas .SetInitialSize (wx .Size (width , height ))
12871277 self .window .GetSizer ().Fit (self .window )
12881278
1289- # Identifiers for toolbar controls - images_wx contains bitmaps for the images
1290- # used in the controls. wxWindows does not provide any stock images, so I've
1291- # 'stolen' those from GTK2, and transformed them into the appropriate format.
1292- # import images_wx
1293-
1279+ # Identifiers for toolbar controls.
12941280
12951281_NTB_AXISMENU = wx .NewId ()
12961282_NTB_AXISMENU_BUTTON = wx .NewId ()
@@ -1302,7 +1288,6 @@ def resize(self, width, height):
13021288_NTB_Y_PAN_DOWN = wx .NewId ()
13031289_NTB_Y_ZOOMIN = wx .NewId ()
13041290_NTB_Y_ZOOMOUT = wx .NewId ()
1305- # _NTB_SUBPLOT =wx.NewId()
13061291_NTB_SAVE = wx .NewId ()
13071292_NTB_CLOSE = wx .NewId ()
13081293
@@ -1326,6 +1311,7 @@ def _load_bitmap(filename):
13261311 return bmp
13271312
13281313
1314+ @cbook .deprecated ("3.0" )
13291315class MenuButtonWx (wx .Button ):
13301316 """
13311317 wxPython does not permit a menu to be incorporated directly into a toolbar.
@@ -1403,7 +1389,7 @@ def updateAxes(self, maxAxis):
14031389 """Ensures that there are entries for max_axis axes in the menu
14041390 (selected by default)."""
14051391 if maxAxis > len (self ._axisId ):
1406- for i in range (len (self ._axisId ) + 1 , maxAxis + 1 , 1 ):
1392+ for i in range (len (self ._axisId ) + 1 , maxAxis + 1 ):
14071393 menuId = wx .NewId ()
14081394 self ._axisId .append (menuId )
14091395 self ._menu .Append (menuId , "Axis %d" % i ,
@@ -1676,16 +1662,10 @@ class StatusBarWx(wx.StatusBar):
16761662 def __init__ (self , parent ):
16771663 wx .StatusBar .__init__ (self , parent , - 1 )
16781664 self .SetFieldsCount (2 )
1679- self .SetStatusText ("None" , 1 )
1680- # self.SetStatusText("Measurement: None", 2)
1681- # self.Reposition()
16821665
16831666 def set_function (self , string ):
16841667 self .SetStatusText ("%s" % string , 1 )
16851668
1686- # def set_measurement(self, string):
1687- # self.SetStatusText("Measurement: %s" % string, 2)
1688-
16891669
16901670# tools for matplotlib.backend_managers.ToolManager:
16911671# for now only SaveFigure, SetCursor and Rubberband are implemented
@@ -1844,6 +1824,7 @@ def trigger(self, *args, **kwargs):
18441824
18451825# < Additions for printing support: Matt Newville
18461826
1827+ @cbook .deprecated ("3.0" )
18471828class PrintoutWx (wx .Printout ):
18481829 """
18491830 Simple wrapper around wx Printout class -- all the real work
@@ -1925,7 +1906,6 @@ def OnPrintPage(self, page):
19251906 self .canvas .figure .dpi = fig_dpi
19261907 self .canvas .draw ()
19271908 return True
1928- # >
19291909
19301910
19311911@_Backend .export
0 commit comments