@@ -53,9 +53,6 @@ def fn_name(): return sys._getframe(1).f_code.co_name
53
53
IMAGE_FORMAT .sort ()
54
54
IMAGE_FORMAT_DEFAULT = 'png'
55
55
56
- DBL_BUFFER = True
57
- #DBL_BUFFER = False # test to see if switching double buffering off is useful
58
-
59
56
60
57
cursord = {
61
58
cursors .MOVE : gtk .gdk .Cursor (gtk .gdk .FLEUR ),
@@ -241,26 +238,24 @@ def _render_figure(self, width, height):
241
238
Should not be overridden by GTK backends
242
239
"""
243
240
if DEBUG : print 'FigureCanvasGTK.%s' % fn_name ()
244
- if DBL_BUFFER :
245
- create_pixmap = False
246
- if width > self ._pixmap_width :
247
- # increase the pixmap in 10%+ (rather than 1 pixel) steps
248
- self ._pixmap_width = max (int (self ._pixmap_width * 1.1 ),
249
- width )
250
- create_pixmap = True
251
-
252
- if height > self ._pixmap_height :
253
- self ._pixmap_height = max (int (self ._pixmap_height * 1.1 ),
241
+
242
+ create_pixmap = False
243
+ if width > self ._pixmap_width :
244
+ # increase the pixmap in 10%+ (rather than 1 pixel) steps
245
+ self ._pixmap_width = max (int (self ._pixmap_width * 1.1 ),
246
+ width )
247
+ create_pixmap = True
248
+
249
+ if height > self ._pixmap_height :
250
+ self ._pixmap_height = max (int (self ._pixmap_height * 1.1 ),
254
251
height )
255
- create_pixmap = True
252
+ create_pixmap = True
256
253
257
- if create_pixmap :
258
- if DEBUG : print 'FigureCanvasGTK.%s new pixmap' % fn_name ()
259
- self ._pixmap = gtk .gdk .Pixmap (self .window , self ._pixmap_width ,
260
- self ._pixmap_height )
261
- self ._renderer ._set_pixmap (self ._pixmap )
262
- else :
263
- self ._renderer ._set_pixmap (self .window )
254
+ if create_pixmap :
255
+ if DEBUG : print 'FigureCanvasGTK.%s new pixmap' % fn_name ()
256
+ self ._pixmap = gtk .gdk .Pixmap (self .window , self ._pixmap_width ,
257
+ self ._pixmap_height )
258
+ self ._renderer ._set_pixmap (self ._pixmap )
264
259
265
260
self ._renderer ._set_width_height (width , height )
266
261
self .figure .draw (self ._renderer )
@@ -272,17 +267,18 @@ def expose_event(self, widget, event):
272
267
"""
273
268
if DEBUG : print 'FigureCanvasGTK.%s' % fn_name ()
274
269
275
- if DBL_BUFFER :
276
- if self ._draw_pixmap and GTK_WIDGET_DRAWABLE (self ):
277
- width , height = self .allocation .width , self .allocation .height
278
- self ._render_figure (width , height )
279
- self .window .set_back_pixmap (self ._pixmap , False )
280
- self .window .clear () # draw pixmap as the gdk.Window's bg
281
- self ._draw_pixmap = False
282
- else :
283
- if GTK_WIDGET_DRAWABLE (self ):
284
- width , height = self .allocation .width , self .allocation .height
285
- self ._render_figure (width , height )
270
+ if not GTK_WIDGET_DRAWABLE (self ):
271
+ return False
272
+
273
+ if self ._draw_pixmap :
274
+ width , height = self .allocation .width , self .allocation .height
275
+ self ._render_figure (width , height )
276
+ self .window .set_back_pixmap (self ._pixmap , False )
277
+ self .window .clear () # draw pixmap as the gdk.Window's bg
278
+ self ._draw_pixmap = False
279
+ else : # workaround pygtk 2.6 problem - bg not being redrawn
280
+ self .window .clear_area (event .area .x , event .area .y ,
281
+ event .area .width , event .area .height )
286
282
287
283
return False # allow signal to propagate further
288
284
@@ -313,16 +309,10 @@ def print_figure(self, filename, dpi=150, facecolor='w', edgecolor='w',
313
309
314
310
ext = ext .lower ()
315
311
if ext in ('jpg' , 'png' ): # native printing
316
- global DBL_BUFFER
317
- dbl_buffer_save = DBL_BUFFER
318
- DBL_BUFFER = True # need to use pixmap not gdk.window
319
-
320
312
width , height = self .figure .get_width_height ()
321
313
width , height = int (width ), int (height )
322
314
self ._render_figure (width , height )
323
315
324
- DBL_BUFFER = dbl_buffer_save
325
-
326
316
# jpg colors don't match the display very well, png colors match
327
317
# better
328
318
pixbuf = gtk .gdk .Pixbuf (gtk .gdk .COLORSPACE_RGB , 0 , 8 ,
0 commit comments