66 import pygtk
77 pygtk .require ('2.0' )
88except :
9- print sys .exc_info ()[1 ]
9+ print >> sys .stderr , sys . exc_info ()[1 ] # can't use verbose(), until its loaded!
1010 raise SystemExit ('PyGTK version 1.99.16 or greater is required to run the GTK/GTKAgg Matplotlib backend' )
1111
1212import gobject
3838
3939try : from matplotlib .mathtext import math_parse_s_ft2font
4040except ImportError :
41- print >> sys . stderr , 'backend_gtk could not import mathtext (build with ft2font)'
41+ verbose . report_error ( 'backend_gtk could not import mathtext (build with ft2font)' )
4242 useMathText = False
4343else : useMathText = True
4444
@@ -177,8 +177,6 @@ def draw_image(self, x, y, im, origin, bbox):
177177 is the distance from top. If origin is lower, y is the
178178 distance from bottom
179179 """
180- #print 'draw_image'
181-
182180 if bbox is not None :
183181 l ,b ,w ,h = bbox .get_bounds ()
184182 #rectangle = (int(l), self.height-int(b+h),
@@ -199,7 +197,7 @@ def draw_image(self, x, y, im, origin, bbox):
199197 except AttributeError :
200198 pa = pb .pixel_array
201199 except RuntimeError , exc : # pygtk was not compiled with Numeric Python support
202- print >> sys . stderr , 'Error:' , exc
200+ verbose . report_error ( 'Error: %s' % exc )
203201 return
204202
205203 pa [:,:,:] = X
@@ -255,7 +253,7 @@ def draw_polygon(self, gc, rgbFace, points):
255253 self .gdkDrawable .draw_polygon (gc .gdkGC , False , points )
256254
257255
258- def draw_rectangle (self , gc , rgbFace , x , y , width , height ):
256+ def draw_rectangle (self , gcEdge , rgbFace , x , y , width , height ):
259257 """
260258 Draw a rectangle at lower left x,y with width and height
261259 If filled=True, fill the rectangle with the gc foreground
@@ -267,13 +265,13 @@ def draw_rectangle(self, gc, rgbFace, x, y, width, height):
267265
268266
269267 if rgbFace is not None :
270- edgecolor = gc .gdkGC .foreground
268+ edgecolor = gcEdge .gdkGC .foreground
271269 facecolor = colorManager .get_color (rgbFace )
272- gc .gdkGC .foreground = facecolor
273- self .gdkDrawable .draw_rectangle (gc .gdkGC , True , x , y , w , h )
274- gc .gdkGC .foreground = edgecolor
270+ gcEdge .gdkGC .foreground = facecolor
271+ self .gdkDrawable .draw_rectangle (gcEdge .gdkGC , True , x , y , w , h )
272+ gcEdge .gdkGC .foreground = edgecolor
275273
276- self .gdkDrawable .draw_rectangle (gc .gdkGC , False , x , y , w , h )
274+ self .gdkDrawable .draw_rectangle (gcEdge .gdkGC , False , x , y , w , h )
277275
278276
279277 def draw_text (self , gc , x , y , s , prop , angle , ismath ):
@@ -387,7 +385,7 @@ def _draw_rotated_text(self, gc, x, y, s, prop, angle):
387385 visual = gdrawable .get_visual (),
388386 width = w , height = h )
389387 if imageFlip is None or imageBack is None or imageVert is None :
390- print >> sys . stderr , "Could not renderer vertical text" , s
388+ verbose . report_error ( "Could not renderer vertical text" , s )
391389 return
392390 imageFlip .set_colormap (gdrawable .get_colormap ())
393391 for i in range (w ):
@@ -637,13 +635,16 @@ def __init__(self, figure):
637635
638636 self .set_flags (gtk .CAN_FOCUS )
639637 self .grab_focus ()
640- # self.pixmap_width, self.pixmap_height = -1, -1
641638 self ._isRealized = False
642639 self ._gpixmap = None
643640 self ._doplot = True
644641 self ._printQued = []
645- self ._idleID = 0 # used in gtkagg
646- self ._new_pixmap = True
642+ self ._idleID = 0 # used in gtkAgg
643+
644+ self ._pixmap = None # *_pixmap* used by gtkCairo
645+ self ._new_pixmap = True
646+ self ._pixmap_width = - 1
647+ self ._pixmap_height = - 1
647648
648649 self ._button = None # the button pressed
649650 self ._key = None # the key pressed
0 commit comments