6
6
import pygtk
7
7
pygtk .require ('2.0' )
8
8
except :
9
- print sys .exc_info ()[1 ]
9
+ print >> sys .stderr , sys . exc_info ()[1 ] # can't use verbose(), until its loaded!
10
10
raise SystemExit ('PyGTK version 1.99.16 or greater is required to run the GTK/GTKAgg Matplotlib backend' )
11
11
12
12
import gobject
38
38
39
39
try : from matplotlib .mathtext import math_parse_s_ft2font
40
40
except 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)' )
42
42
useMathText = False
43
43
else : useMathText = True
44
44
@@ -177,8 +177,6 @@ def draw_image(self, x, y, im, origin, bbox):
177
177
is the distance from top. If origin is lower, y is the
178
178
distance from bottom
179
179
"""
180
- #print 'draw_image'
181
-
182
180
if bbox is not None :
183
181
l ,b ,w ,h = bbox .get_bounds ()
184
182
#rectangle = (int(l), self.height-int(b+h),
@@ -199,7 +197,7 @@ def draw_image(self, x, y, im, origin, bbox):
199
197
except AttributeError :
200
198
pa = pb .pixel_array
201
199
except RuntimeError , exc : # pygtk was not compiled with Numeric Python support
202
- print >> sys . stderr , 'Error:' , exc
200
+ verbose . report_error ( 'Error: %s' % exc )
203
201
return
204
202
205
203
pa [:,:,:] = X
@@ -255,7 +253,7 @@ def draw_polygon(self, gc, rgbFace, points):
255
253
self .gdkDrawable .draw_polygon (gc .gdkGC , False , points )
256
254
257
255
258
- def draw_rectangle (self , gc , rgbFace , x , y , width , height ):
256
+ def draw_rectangle (self , gcEdge , rgbFace , x , y , width , height ):
259
257
"""
260
258
Draw a rectangle at lower left x,y with width and height
261
259
If filled=True, fill the rectangle with the gc foreground
@@ -267,13 +265,13 @@ def draw_rectangle(self, gc, rgbFace, x, y, width, height):
267
265
268
266
269
267
if rgbFace is not None :
270
- edgecolor = gc .gdkGC .foreground
268
+ edgecolor = gcEdge .gdkGC .foreground
271
269
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
275
273
276
- self .gdkDrawable .draw_rectangle (gc .gdkGC , False , x , y , w , h )
274
+ self .gdkDrawable .draw_rectangle (gcEdge .gdkGC , False , x , y , w , h )
277
275
278
276
279
277
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):
387
385
visual = gdrawable .get_visual (),
388
386
width = w , height = h )
389
387
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 )
391
389
return
392
390
imageFlip .set_colormap (gdrawable .get_colormap ())
393
391
for i in range (w ):
@@ -637,13 +635,16 @@ def __init__(self, figure):
637
635
638
636
self .set_flags (gtk .CAN_FOCUS )
639
637
self .grab_focus ()
640
- # self.pixmap_width, self.pixmap_height = -1, -1
641
638
self ._isRealized = False
642
639
self ._gpixmap = None
643
640
self ._doplot = True
644
641
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
647
648
648
649
self ._button = None # the button pressed
649
650
self ._key = None # the key pressed
0 commit comments