Skip to content

Commit 8193c81

Browse files
author
Steve Chaplin
committed
SC 26/10/2004
svn path=/trunk/matplotlib/; revision=614
1 parent f2176a3 commit 8193c81

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

lib/matplotlib/backends/backend_gtk.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import pygtk
77
pygtk.require('2.0')
88
except:
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

1212
import gobject
@@ -38,7 +38,7 @@
3838

3939
try: from matplotlib.mathtext import math_parse_s_ft2font
4040
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)')
4242
useMathText = False
4343
else: 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

lib/matplotlib/backends/backend_template.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ def error_msg_template(msg, *args):
7070
verbose.report('Error: %s'%msg)
7171
sys.exit()
7272

73+
7374
class RendererTemplate(RendererBase):
7475
"""
7576
The renderer handles all the drawing primitives using a graphics
7677
context instance that controls the colors/styles
7778
"""
7879

79-
8080
def get_canvas_width_height(self):
8181
'return the canvas width and height in display coords'
8282
return 100, 100
@@ -158,10 +158,10 @@ def draw_polygon(self, gcEdge, rgbFace, points):
158158

159159
def draw_rectangle(self, gcEdge, rgbFace, x, y, width, height):
160160
"""
161-
Draw a rectangle at lower left x,y with width and height.
162-
163-
If rgbFace is not None, fill the rectangle with it. gcEdge
164-
is a GraphicsContext instance
161+
Draw a non-filled rectangle at x,y (lower left) with width and height,
162+
using the GraphicsContext gcEdge.
163+
Draw a filled rectangle within it of color rgbFace, if rgbFace is not
164+
None.
165165
"""
166166
pass
167167

@@ -204,7 +204,7 @@ class GraphicsContextTemplate(GraphicsContextBase):
204204
class for the GTK backend. If it's more appropriate to do the
205205
mapping at the renderer level (as in the postscript backend), you
206206
don't need to override any of the GC methods. If it's more
207-
approritate to wrap an instance (as in the GTK backend) and do the
207+
appropriate to wrap an instance (as in the GTK backend) and do the
208208
mapping here, you'll need to override several of the setter
209209
methods.
210210
"""

0 commit comments

Comments
 (0)