8000 SC · matplotlib/matplotlib@06e322e · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 06e322e

Browse files
author
Steve Chaplin
committed
SC
svn path=/trunk/matplotlib/; revision=1400
1 parent 039af43 commit 06e322e

File tree

2 files changed

+31
-38
lines changed

2 files changed

+31
-38
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
New entries should be added at the top
22

3+
2005-06-01 backend_gtk.py remove DBL_BUFFER, add like to expose_event to
4+
try to fix pygtk 2.6 redraw problem - SC
5+
36
2005-06-01 The default behavior of ScalarFormatter now renders scientific
47
notation and large numerical offsets in a label at the end of
58
the axis. - DSD

lib/matplotlib/backends/backend_gtk.py

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ def fn_name(): return sys._getframe(1).f_code.co_name
5353
IMAGE_FORMAT.sort()
5454
IMAGE_FORMAT_DEFAULT = 'png'
5555

56-
DBL_BUFFER = True
57-
#DBL_BUFFER = False # test to see if switching double buffering off is useful
58-
5956

6057
cursord = {
6158
cursors.MOVE : gtk.gdk.Cursor(gtk.gdk.FLEUR),
@@ -241,26 +238,24 @@ def _render_figure(self, width, height):
241238
Should not be overridden by GTK backends
242239
"""
243240
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),
254251
height)
255-
create_pixmap = True
252+
create_pixmap = True
256253

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)
264259

265260
self._renderer._set_width_height (width, height)
266261
self.figure.draw (self._renderer)
@@ -272,17 +267,18 @@ def expose_event(self, widget, event):
272267
"""
273268
if DEBUG: print 'FigureCanvasGTK.%s' % fn_name()
274269

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)
286282

287283
return False # allow signal to propagate further
288284

@@ -313,16 +309,10 @@ def print_figure(self, filename, dpi=150, facecolor='w', edgecolor='w',
313309

314310
ext = ext.lower()
315311
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-
320312
width, height = self.figure.get_width_height()
321313
width, height = int(width), int(height)
322314
self._render_figure(width, height)
323315

324-
DBL_BUFFER = dbl_buffer_save
325-
326316
# jpg colors don't match the display very well, png colors match
327317
# better
328318
pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, 0, 8,

0 commit comments

Comments
 (0)
0