@@ -452,7 +452,11 @@ def __init__(self, canvas, window):
452
452
self .win = window
453
453
GObject .GObject .__init__ (self )
454
454
NavigationToolbar2 .__init__ (self , canvas )
455
- self .ctx = None
455
+
456
+ @cbook .deprecated ("3.3" )
457
+ @property
458
+ def ctx (self ):
459
+ return self .canvas .get_property ("window" ).cairo_create ()
456
460
457
461
def set_message (self , s ):
458
462
self .message .set_label (s )
@@ -464,7 +468,7 @@ def set_cursor(self, cursor):
464
468
def draw_rubberband (self , event , x0 , y0 , x1 , y1 ):
465
469
# adapted from
466
470
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/189744
467
- self . ctx = self .canvas .get_property ("window" ).cairo_create ()
471
+ ctx = self .canvas .get_property ("window" ).cairo_create ()
468
472
469
473
# todo: instead of redrawing the entire figure, copy the part of
470
474
# the figure that was covered by the previous rubberband rectangle
@@ -477,11 +481,11 @@ def draw_rubberband(self, event, x0, y0, x1, y1):
477
481
h = abs (y1 - y0 )
478
482
rect = [int (val ) for val in (min (x0 , x1 ), min (y0 , y1 ), w , h )]
479
483
480
- self . ctx .new_path ()
481
- self . ctx .set_line_width (0.5 )
482
- self . ctx .rectangle (rect [ 0 ], rect [ 1 ], rect [ 2 ], rect [ 3 ] )
483
- self . ctx .set_source_rgb (0 , 0 , 0 )
484
- self . ctx .stroke ()
484
+ ctx .new_path ()
485
+ ctx .set_line_width (0.5 )
486
+ ctx .rectangle (* rect )
487
+ ctx .set_source_rgb (0 , 0 , 0 )
488
+ ctx .stroke ()
485
489
486
490
def _init_toolbar (self ):
487
491
self .set_style (Gtk .ToolbarStyle .ICONS )
0 commit comments