@@ -47,8 +47,9 @@ def fn_name(): return sys._getframe(1).f_code.co_name
4747PIXELS_PER_INCH = 96
4848
4949# Image formats that this backend supports - for FileChooser and print_figure()
50- IMAGE_FORMAT = ['bmp' , 'eps' , 'jpg' , 'png' , 'ps' , 'svg' ]
51- #IMAGE_FORMAT = ['bmp', 'eps', 'jpg', 'png', 'pdf', 'ps', 'svg'] # pdf not ready yet
50+ IMAGE_FORMAT = ['bmp' , 'eps' , 'jpg' , 'png' , 'ps' , 'svg' ]
51+ # pdf not ready yet
52+ #IMAGE_FORMAT = ['bmp', 'eps', 'jpg', 'png', 'pdf', 'ps', 'svg']
5253IMAGE_FORMAT .sort ()
5354IMAGE_FORMAT_DEFAULT = 'png'
5455
@@ -64,7 +65,9 @@ def fn_name(): return sys._getframe(1).f_code.co_name
6465 }
6566
6667# ref gtk+/gtk/gtkwidget.h
67- def GTK_WIDGET_DRAWABLE (w ): flags = w .flags (); return flags & gtk .VISIBLE != 0 and flags & gtk .MAPPED != 0
68+ def GTK_WIDGET_DRAWABLE (w ):
69+ flags = w .flags ();
70+ return flags & gtk .VISIBLE != 0 and flags & gtk .MAPPED != 0
6871
6972
7073def draw_if_interactive ():
@@ -118,7 +121,7 @@ def __init__(self, figure):
118121 FigureCanvasBase .__init__ (self , figure )
119122 gtk .DrawingArea .__init__ (self )
120123
121- self ._idleID = 0 # used in gtkAgg
124+ self ._idleID = 0
122125 self ._draw_pixmap = True
123126 self ._pixmap_width = - 1
124127 self ._pixmap_height = - 1
@@ -242,11 +245,13 @@ def _render_figure(self, width, height):
242245 create_pixmap = False
243246 if width > self ._pixmap_width :
244247 # increase the pixmap in 10%+ (rather than 1 pixel) steps
245- self ._pixmap_width = max (int (self ._pixmap_width * 1.1 ), width )
248+ self ._pixmap_width = max (int (self ._pixmap_width * 1.1 ),
249+ width )
246250 create_pixmap = True
247251
248252 if height > self ._pixmap_height :
249- self ._pixmap_height = max (int (self ._pixmap_height * 1.1 ), height )
253+ self ._pixmap_height = max (int (self ._pixmap_height * 1.1 ),
254+ height )
250255 create_pixmap = True
251256
252257 if create_pixmap :
@@ -298,7 +303,8 @@ def print_figure(self, filename, dpi=150, facecolor='w', edgecolor='w',
298303 origWIn , origHIn = self .figure .get_size_inches ()
299304
300305 if self .flags () & gtk .REALIZED == 0 :
301- # for self.window(for pixmap) and has a side effect of altering figure width,height (via configure-event?)
306+ # for self.window(for pixmap) and has a side effect of altering
307+ # figure width,height (via configure-event?)
302308 gtk .DrawingArea .realize (self )
303309
304310 self .figure .dpi .set (dpi )
@@ -317,7 +323,8 @@ def print_figure(self, filename, dpi=150, facecolor='w', edgecolor='w',
317323
318324 DBL_BUFFER = dbl_buffer_save
319325
320- # jpg colors don't match the display very well, png colors match better
326+ # jpg colors don't match the display very well, png colors match
327+ # better
321328 pixbuf = gtk .gdk .Pixbuf (gtk .gdk .COLORSPACE_RGB , 0 , 8 ,
322329 width , height )
323330 pixbuf .get_from_drawable (self ._pixmap , self ._pixmap .get_colormap (),
@@ -338,7 +345,8 @@ def print_figure(self, filename, dpi=150, facecolor='w', edgecolor='w',
338345
339346 try :
340347 fc = self .switch_backends (FigureCanvas )
341- fc .print_figure (filename , dpi , facecolor , edgecolor , orientation )
348+ fc .print_figure (filename , dpi , facecolor , edgecolor ,
349+ orientation )
342350 except IOError , exc :
343351 error_msg_gtk ("Save figure failure:\n %s: %s" %
344352 (exc .filename , exc .strerror ), parent = self )
@@ -354,7 +362,8 @@ def print_figure(self, filename, dpi=150, facecolor='w', edgecolor='w',
354362 parent = self )
355363 else :
356364 fc = self .switch_backends (FigureCanvas )
357- fc .print_figure (filename , dpi , facecolor , edgecolor , orientation )
365+ fc .print_figure (filename , dpi , facecolor , edgecolor ,
366+ orientation )
358367
359368 elif ext in ('pdf' ,):
360369 try :
@@ -365,7 +374,8 @@ def print_figure(self, filename, dpi=150, facecolor='w', edgecolor='w',
365374 parent = self )
366375 else :
367376 fc = self .switch_backends (FigureCanvas )
368- fc .print_figure (filename , dpi , facecolor , edgecolor , orientation )
377+ fc .print_figure (filename , dpi , facecolor , edgecolor ,
378+ orientation )
369379
370380 else :
371381 error_msg_gtk ('Format "%s" is not supported.\n Supported formats are %s.' %
@@ -501,7 +511,7 @@ def draw_rubberband(self, event, x0, y0, x1, y1):
501511
502512 ax = event .inaxes
503513 l ,b ,w ,h = [int (val ) for val in ax .bbox .get_bounds ()]
504- b = int (height )- (b + h ) # b = y = int(height)-(b+h) # y not used
514+ b = int (height )- (b + h )
505515 axrect = l ,b ,w ,h
506516 self ._imageBack = axrect , drawable .get_image (* axrect )
507517 drawable .draw_rectangle (gc , False , * rect )
@@ -573,7 +583,9 @@ def _init_toolbar2_4(self):
573583
574584 toolitem = gtk .SeparatorToolItem ()
575585 self .insert (toolitem , - 1 )
576- toolitem .set_draw (False ) # set_draw() not making separator invisible, bug #143692 fixed Jun 06 2004, will be in GTK+ 2.6
586+ # set_draw() not making separator invisible,
587+ # bug #143692 fixed Jun 06 2004, will be in GTK+ 2.6
588+ toolitem .set_draw (False )
577589 toolitem .set_expand (True )
578590
579591 toolitem = gtk .ToolItem ()
@@ -608,21 +620,25 @@ class NavigationToolbar(gtk.Toolbar):
608620 gtk .STOCK_GO_BACK , 'panx' , - 1 , True ),
609621 ('Right' , 'Pan right with click or wheel mouse (bidirectional)' ,
610622 gtk .STOCK_GO_FORWARD , 'panx' , 1 , True ),
611- ('Zoom In X' , 'Zoom In X (shrink the x axis limits) with click or wheel'
623+ ('Zoom In X' ,
624+ 'Zoom In X (shrink the x axis limits) with click or wheel'
612625 ' mouse (bidirectional)' ,
613626 gtk .STOCK_ZOOM_IN , 'zoomx' , 1 , True ),
614- ('Zoom Out X' , 'Zoom Out X (expand the x axis limits) with click or wheel'
627+ ('Zoom Out X' ,
628+ 'Zoom Out X (expand the x axis limits) with click or wheel'
615629 ' mouse (bidirectional)' ,
616630 gtk .STOCK_ZOOM_OUT , 'zoomx' , - 1 , True ),
617631 (None , None , None , None , None , None ,),
618632 ('Up' , 'Pan up with click or wheel mouse (bidirectional)' ,
619633 gtk .STOCK_GO_UP , 'pany' , 1 , True ),
620634 ('Down' , 'Pan down with click or wheel mouse (bidirectional)' ,
621635 gtk .STOCK_GO_DOWN , 'pany' , - 1 , True ),
622- ('Zoom In Y' , 'Zoom in Y (shrink the y axis limits) with click or wheel'
636+ ('Zoom In Y' ,
637+ 'Zoom in Y (shrink the y axis limits) with click or wheel'
623638 ' mouse (bidirectional)' ,
624639 gtk .STOCK_ZOOM_IN , 'zoomy' , 1 , True ),
625- ('Zoom Out Y' , 'Zoom Out Y (expand the y axis limits) with click or wheel'
640+ ('Zoom Out Y' ,
641+ 'Zoom Out Y (expand the y axis limits) with click or wheel'
626642 ' mouse (bidirectional)' ,
627643 gtk .STOCK_ZOOM_OUT , 'zoomy' , - 1 , True ),
628644 (None , None , None , None , None , None ,),
@@ -639,7 +655,8 @@ def __init__(self, canvas, window):
639655 gtk .Toolbar .__init__ (self )
640656
641657 self .canvas = canvas
642- self .win = window # Note: gtk.Toolbar already has a 'window' attribute
658+ # Note: gtk.Toolbar already has a 'window' attribute
659+ self .win = window
643660
644661 self .set_style (gtk .TOOLBAR_ICONS )
645662
@@ -671,7 +688,8 @@ def _create_toolitems_2_4(self):
671688 text )
672689 self .insert (tbutton , - 1 )
673690 if callback_arg :
674- tbutton .connect ('clicked' , getattr (self , callback ), callback_arg )
691+ tbutton .connect ('clicked' , getattr (self , callback ),
692+ callback_arg )
675693 else :
676694 tbutton .connect ('clicked' , getattr (self , callback ))
677695 if scroll :
@@ -681,9 +699,10 @@ def _create_toolitems_2_4(self):
681699 # Axes toolitem, is empty at start, update() adds a menu if >=2 axes
682700 self .axes_toolitem = gtk .ToolItem ()
683701 self .insert (self .axes_toolitem , 0 )
684- self .axes_toolitem .set_tooltip (self .tooltips ,
685- tip_text = 'Select axes that controls affect' ,
686- tip_private = 'Private' )
702+ self .axes_toolitem .set_tooltip (
703+ self .tooltips ,
704+ tip_text = 'Select axes that controls affect' ,
705+ tip_private = 'Private' )
687706
688707 align = gtk .Alignment (xalign = 0.5 , yalign = 0.5 , xscale = 0.0 , yscale = 0.0 )
689708 self .axes_toolitem .add (align )
@@ -709,7 +728,8 @@ def position_menu (menu):
709728 return x , y , True
710729
711730 def button_clicked (button , data = None ):
712- self .axismenu .popup (None , None , position_menu , 0 , gtk .get_current_event_time ())
731+ self .axismenu .popup (None , None , position_menu , 0 ,
732+ gtk .get_current_event_time ())
713733
714734 self .menubutton .connect ("clicked" , button_clicked )
715735
0 commit comments