@@ -47,8 +47,9 @@ def fn_name(): return sys._getframe(1).f_code.co_name
47
47
PIXELS_PER_INCH = 96
48
48
49
49
# 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']
52
53
IMAGE_FORMAT .sort ()
53
54
IMAGE_FORMAT_DEFAULT = 'png'
54
55
@@ -64,7 +65,9 @@ def fn_name(): return sys._getframe(1).f_code.co_name
64
65
}
65
66
66
67
# 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
68
71
69
72
70
73
def draw_if_interactive ():
@@ -118,7 +121,7 @@ def __init__(self, figure):
118
121
FigureCanvasBase .__init__ (self , figure )
119
122
gtk .DrawingArea .__init__ (self )
120
123
121
- self ._idleID = 0 # used in gtkAgg
124
+ self ._idleID = 0
122
125
self ._draw_pixmap = True
123
126
self ._pixmap_width = - 1
124
127
self ._pixmap_height = - 1
@@ -242,11 +245,13 @@ def _render_figure(self, width, height):
242
245
create_pixmap = False
243
246
if width > self ._pixmap_width :
244
247
# 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 )
246
250
create_pixmap = True
247
251
248
252
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 )
250
255
create_pixmap = True
251
256
252
257
if create_pixmap :
@@ -298,7 +303,8 @@ def print_figure(self, filename, dpi=150, facecolor='w', edgecolor='w',
298
303
origWIn , origHIn = self .figure .get_size_inches ()
299
304
300
305
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?)
302
308
gtk .DrawingArea .realize (self )
303
309
304
310
self .figure .dpi .set (dpi )
@@ -317,7 +323,8 @@ def print_figure(self, filename, dpi=150, facecolor='w', edgecolor='w',
317
323
318
324
DBL_BUFFER = dbl_buffer_save
319
325
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
321
328
pixbuf = gtk .gdk .Pixbuf (gtk .gdk .COLORSPACE_RGB , 0 , 8 ,
322
329
width , height )
323
330
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',
338
345
339
346
try :
340
347
fc = self .switch_backends (FigureCanvas )
341
- fc .print_figure (filename , dpi , facecolor , edgecolor , orientation )
348
+ fc .print_figure (filename , dpi , facecolor , edgecolor ,
349
+ orientation )
342
350
except IOError , exc :
343
351
error_msg_gtk ("Save figure failure:\n %s: %s" %
344
352
(exc .filename , exc .strerror ), parent = self )
@@ -354,7 +362,8 @@ def print_figure(self, filename, dpi=150, facecolor='w', edgecolor='w',
354
362
parent = self )
355
363
else :
356
364
fc = self .switch_backends (FigureCanvas )
357
- fc .print_figure (filename , dpi , facecolor , edgecolor , orientation )
365
+ fc .print_figure (filename , dpi , facecolor , edgecolor ,
366
+ orientation )
358
367
359
368
elif ext in ('pdf' ,):
360
369
try :
@@ -365,7 +374,8 @@ def print_figure(self, filename, dpi=150, facecolor='w', edgecolor='w',
365
374
parent = self )
366
375
else :
367
376
fc = self .switch_backends (FigureCanvas )
368
- fc .print_figure (filename , dpi , facecolor , edgecolor , orientation )
377
+ fc .print_figure (filename , dpi , facecolor , edgecolor ,
378
+ orientation )
369
379
370
380
else :
371
381
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):
501
511
502
512
ax = event .inaxes
503
513
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 )
505
515
axrect = l ,b ,w ,h
506
516
self ._imageBack = axrect , drawable .get_image (* axrect )
507
517
drawable .draw_rectangle (gc , False , * rect )
@@ -573,7 +583,9 @@ def _init_toolbar2_4(self):
573
583
574
584
toolitem = gtk .SeparatorToolItem ()
575
585
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 )
577
589
toolitem .set_expand (True )
578
590
579
591
toolitem = gtk .ToolItem ()
@@ -608,21 +620,25 @@ class NavigationToolbar(gtk.Toolbar):
608
620
gtk .STOCK_GO_BACK , 'panx' , - 1 , True ),
609
621
('Right' , 'Pan right with click or wheel mouse (bidirectional)' ,
610
622
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'
612
625
' mouse (bidirectional)' ,
613
626
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'
615
629
' mouse (bidirectional)' ,
616
630
gtk .STOCK_ZOOM_OUT , 'zoomx' , - 1 , True ),
617
631
(None , None , None , None , None , None ,),
618
632
('Up' , 'Pan up with click or wheel mouse (bidirectional)' ,
619
633
gtk .STOCK_GO_UP , 'pany' , 1 , True ),
620
634
('Down' , 'Pan down with click or wheel mouse (bidirectional)' ,
621
635
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'
623
638
' mouse (bidirectional)' ,
624
639
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'
626
642
' mouse (bidirectional)' ,
627
643
gtk .STOCK_ZOOM_OUT , 'zoomy' , - 1 , True ),
628
644
(None , None , None , None , None , None ,),
@@ -639,7 +655,8 @@ def __init__(self, canvas, window):
639
655
gtk .Toolbar .__init__ (self )
640
656
641
657
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
643
660
644
661
self .set_style (gtk .TOOLBAR_ICONS )
645
662
@@ -671,7 +688,8 @@ def _create_toolitems_2_4(self):
671
688
text )
672
689
self .insert (tbutton , - 1 )
673
690
if callback_arg :
674
- tbutton .connect ('clicked' , getattr (self , callback ), callback_arg )
691
+ tbutton .connect ('clicked' , getattr (self , callback ),
692
+ callback_arg )
675
693
else :
676
694
tbutton .connect ('clicked' , getattr (self , callback ))
677
695
if scroll :
@@ -681,9 +699,10 @@ def _create_toolitems_2_4(self):
681
699
# Axes toolitem, is empty at start, update() adds a menu if >=2 axes
682
700
self .axes_toolitem = gtk .ToolItem ()
683
701
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' )
687
706
688
707
align = gtk .Alignment (xalign = 0.5 , yalign = 0.5 , xscale = 0.0 , yscale = 0.0 )
689
708
self .axes_toolitem .add (align )
@@ -709,7 +728,8 @@ def position_menu (menu):
709
728
return x , y , True
710
729
711
730
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 ())
713
733
714
734
self .menubutton .connect ("clicked" , button_clicked )
715
735
0 commit comments