4040_DEBUG_lvls = {1 : 'Low ' , 2 : 'Med ' , 3 : 'High' , 4 : 'Error' }
4141
4242
43+ @cbook .deprecated ("3.3" )
4344def DEBUG_MSG (string , lvl = 3 , o = None ):
4445 if lvl >= _DEBUG :
4546 print (f"{ _DEBUG_lvls [lvl ]} - { string } in { type (o )} " )
@@ -198,7 +199,7 @@ def __init__(self, bitmap, dpi):
198199 alternative = "wxagg" , addendum = "See the Matplotlib usage FAQ for "
199200 "more info on backends." )
200201 RendererBase .__init__ (self )
201- DEBUG_MSG ( " __init__()" , 1 , self )
202+ _log . debug ( "%s - __init__()" , type ( self ) )
202203 self .width = bitmap .GetWidth ()
203204 self .height = bitmap .GetHeight ()
204205 self .bitmap = bitmap
@@ -301,7 +302,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
301302
302303 if ismath :
303304 s = cbook .strip_math (s )
304- DEBUG_MSG ( " draw_text()" , 1 , self )
305+ _log . debug ( "%s - draw_text()" , type ( self ) )
305306 gc .select ()
306307 self .handle_clip_rectangle (gc )
307308 gfx_ctx = gc .gfx_ctx
@@ -326,7 +327,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
326327
327328 def new_gc (self ):
328329 # docstring inherited
329- DEBUG_MSG ( ' new_gc()' , 2 , self )
330+ _log . debug ( "%s - new_gc()" , type ( self ) )
330331 self .gc = GraphicsContextWx (self .bitmap , self )
331332 self .gc .select ()
332333 self .gc .unselect ()
@@ -346,7 +347,7 @@ def get_wx_font(self, s, prop):
346347 Return a wx font. Cache instances in a font dictionary for
347348 efficiency
348349 """
349- DEBUG_MSG ( " get_wx_font()" , 1 , self )
350+ _log . debug ( "%s - get_wx_font()" , type ( self ) )
350351
351352 key = hash (prop )
352353 fontprop = prop
@@ -408,8 +409,7 @@ class GraphicsContextWx(GraphicsContextBase):
408409 def __init__ (self , bitmap , renderer ):
409410 GraphicsContextBase .__init__ (self )
410411 # assert self.Ok(), "wxMemoryDC not OK to use"
411- DEBUG_MSG ("__init__()" , 1 , self )
412- DEBUG_MSG ("__init__() 2: %s" % bitmap , 1 , self )
412+ _log .debug ("%s - __init__(): %s" , type (self ), bitmap )
413413
414414 dc , gfx_ctx = self ._cache .get (bitmap , (None , None ))
415415 if dc is None :
@@ -445,7 +445,7 @@ def set_foreground(self, fg, isRGBA=None):
445445 # Here we set both to the same colour - if a figure is not to be
446446 # filled, the renderer will set the brush to be transparent
447447 # Same goes for text foreground...
448- DEBUG_MSG ( " set_foreground()" , 1 , self )
448+ _log . debug ( "%s - set_foreground()" , type ( self ) )
449449 self .select ()
450450 GraphicsContextBase .set_foreground (self , fg , isRGBA )
451451
@@ -456,7 +456,7 @@ def set_foreground(self, fg, isRGBA=None):
456456 def set_linewidth (self , w ):
457457 # docstring inherited
458458 w = float (w )
459- DEBUG_MSG ( " set_linewidth()" , 1 , self )
459+ _log . debug ( "%s - set_linewidth()" , type ( self ) )
460460 self .select ()
461461 if 0 < w < 1 :
462462 w = 1
@@ -470,7 +470,7 @@ def set_linewidth(self, w):
470470
471471 def set_capstyle (self , cs ):
472472 # docstring inherited
473- DEBUG_MSG ( " set_capstyle()" , 1 , self )
473+ _log . debug ( "%s - set_capstyle()" , type ( self ) )
474474 self .select ()
475475 GraphicsContextBase .set_capstyle (self , cs )
476476 self ._pen .SetCap (GraphicsContextWx ._capd [self ._capstyle ])
@@ -479,7 +479,7 @@ def set_capstyle(self, cs):
479479
480480 def set_joinstyle (self , js ):
481481 # docstring inherited
482- DEBUG_MSG ( " set_joinstyle()" , 1 , self )
482+ _log . debug ( "%s - set_joinstyle()" , type ( self ) )
483483 self .select ()
484484 GraphicsContextBase .set_joinstyle (self , js )
485485 self ._pen .SetJoin (GraphicsContextWx ._joind [self ._joinstyle ])
@@ -488,7 +488,7 @@ def set_joinstyle(self, js):
488488
489489 def get_wxcolour (self , color ):
490490 """return a wx.Colour from RGB format"""
491- DEBUG_MSG ( " get_wx_color()" , 1 , self )
491+ _log . debug ( "%s - get_wx_color()" , type ( self ) )
492492 if len (color ) == 3 :
493493 r , g , b = color
494494 r *= 255
@@ -600,7 +600,7 @@ def __init__(self, parent, id, figure):
600600
601601 # Create the drawing bitmap
602602 self .bitmap = wx .Bitmap (w , h )
603- DEBUG_MSG ( " __init__() - bitmap w:%d h:%d" % ( w , h ), 2 , self )
603+ _log . debug ( "%s - __init__() - bitmap w:%d h:%d", type ( self ), w , h )
604604 # TODO: Add support for 'point' inspection and plot navigation.
605605 self ._isDrawn = False
606606
@@ -642,7 +642,7 @@ def Copy_to_Clipboard(self, event=None):
642642
643643 def draw_idle (self ):
644644 # docstring inherited
645- DEBUG_MSG ( " draw_idle()" , 1 , self )
645+ _log . debug ( "%s - draw_idle()" , type ( self ) )
646646 self ._isDrawn = False # Force redraw
647647 # Triggering a paint event is all that is needed to defer drawing
648648 # until later. The platform will send the event when it thinks it is
@@ -702,7 +702,7 @@ def gui_repaint(self, drawDC=None, origin='WX'):
702702
703703 The 'WXAgg' backend sets origin accordingly.
704704 """
705- DEBUG_MSG ( " gui_repaint()" , 1 , self )
705+ _log . debug ( "%s - gui_repaint()" , type ( self ) )
706706 if self .IsShownOnScreen ():
707707 if not drawDC :
708708 # not called from OnPaint use a ClientDC
@@ -740,11 +740,8 @@ def print_figure(self, filename, *args, **kwargs):
740740 self .draw ()
741741
742742 def _onPaint (self , evt ):
743- """
744- Called when wxPaintEvt is generated
745- """
746-
747- DEBUG_MSG ("_onPaint()" , 1 , self )
743+ """Called when wxPaintEvt is generated."""
744+ _log .debug ("%s - _onPaint()" , type (self ))
748745 drawDC = wx .PaintDC (self )
749746 if not self ._isDrawn :
750747 self .draw (drawDC = drawDC )
@@ -760,7 +757,7 @@ def _onSize(self, evt):
760757 is better to take the performance hit and redraw the whole window.
761758 """
762759
763- DEBUG_MSG ( " _onSize()" , 2 , self )
760+ _log . debug ( "%s - _onSize()" , type ( self ) )
764761 sz = self .GetParent ().GetSizer ()
765762 if sz :
766763 si = sz .GetItem (self )
@@ -920,7 +917,7 @@ def draw(self, drawDC=None):
920917 Render the figure using RendererWx instance renderer, or using a
921918 previously defined renderer if none is specified.
922919 """
923- DEBUG_MSG ( " draw()" , 1 , self )
920+ _log . debug ( "%s - draw()" , type ( self ) )
924921 self .renderer = RendererWx (self .bitmap , self .figure .dpi )
925922 self .figure .draw (self .renderer )
926923 self ._isDrawn = True
@@ -1020,7 +1017,7 @@ def __init__(self, num, fig):
10201017 wx .Frame .__init__ (self , parent = None , id = - 1 , pos = pos ,
10211018 title = "Figure %d" % num )
10221019 # Frame will be sized later by the Fit method
1023- DEBUG_MSG ( " __init__()" , 1 , self )
1020+ _log . debug ( "%s - __init__()" , type ( self ) )
10241021 self .num = num
10251022 _set_frame_icon (self )
10261023
@@ -1087,11 +1084,11 @@ def get_canvas(self, fig):
10871084 return FigureCanvasWx (self , - 1 , fig )
10881085
10891086 def get_figure_manager (self ):
1090- DEBUG_MSG ( " get_figure_manager()" , 1 , self )
1087+ _log . debug ( "%s - get_figure_manager()" , type ( self ) )
10911088 return self .figmgr
10921089
10931090 def _onClose (self , evt ):
1094- DEBUG_MSG ( " onClose()" , 1 , self )
1091+ _log . debug ( "%s - onClose()" , type ( self ) )
10951092 self .canvas .close_event ()
10961093 self .canvas .stop_event_loop ()
10971094 Gcf .destroy (self .num )
@@ -1134,7 +1131,7 @@ class FigureManagerWx(FigureManagerBase):
11341131 """
11351132
11361133 def __init__ (self , canvas , num , frame ):
1137- DEBUG_MSG ( " __init__()" , 1 , self )
1134+ _log . debug ( "%s - __init__()" , type ( self ) )
11381135 FigureManagerBase .__init__ (self , canvas , num )
11391136 self .frame = frame
11401137 self .window = frame
@@ -1147,7 +1144,7 @@ def show(self):
11471144 self .canvas .draw ()
11481145
11491146 def destroy (self , * args ):
1150- DEBUG_MSG ( " destroy()" , 1 , self )
1147+ _log . debug ( "%s - destroy()" , type ( self ) )
11511148 self .frame .Destroy ()
11521149 wxapp = wx .GetApp ()
11531150 if wxapp :
@@ -1322,7 +1319,7 @@ def get_canvas(self, frame, fig):
13221319 return type (self .canvas )(frame , - 1 , fig )
13231320
13241321 def _init_toolbar (self ):
1325- DEBUG_MSG ( " _init_toolbar" , 1 , self )
1322+ _log . debug ( "%s - _init_toolbar" , type ( self ) )
13261323
13271324 self ._parent = self .canvas .GetParent ()
13281325
@@ -1384,9 +1381,8 @@ def save_figure(self, *args):
13841381 if dlg .ShowModal () == wx .ID_OK :
13851382 dirname = dlg .GetDirectory ()
13861383 filename = dlg .GetFilename ()
1387- DEBUG_MSG (
1388- 'Save file dir:%s name:%s' %
1389- (dirname , filename ), 3 , self )
1384+ _log .debug ('%s - Save file dir:%s name:%s' ,
1385+ self , dirname , filename )
13901386 format = exts [dlg .GetFilterIndex ()]
13911387 basename , ext = os .path .splitext (filename )
13921388 if ext .startswith ('.' ):
0 commit comments