[cairo-commit] pycairo/examples/cairo_snippets snippets_ps.py, NONE, 1.1 snippets_gtk.py, 1.7, 1.8

Steve Chaplin commit at pdx.freedesktop.org
Fri May 20 01:57:47 PDT 2005


Committed by: stevech1097

Update of /cvs/cairo/pycairo/examples/cairo_snippets
In directory gabe:/tmp/cvs-serv17784/examples/cairo_snippets

Modified Files:
	snippets_gtk.py 
Added Files:
	snippets_ps.py 
Log Message:
SC

--- NEW FILE: snippets_ps.py ---
#!/usr/bin/env python
"""Python version of cairo-demo/cairo_snippets/cairo_snippets_ps.c
create a file for each example rather than one large file for all examples
"""
from __future__ import division
from math import pi as M_PI  # used by many snippets
import sys

import cairo

from snippets import snip_list, snippet_normalize, snippet_set_bg_svg

X_inches, Y_inches = 2, 2
width, height = X_inches * 72, Y_inches * 72  # used by snippet_normalize()

Verbose_mode = True

def do_snippet (snippet):
    if Verbose_mode:
        print 'processing %s' % snippet,
    
    filename = 'snippets/%s.ps' % snippet
    surface = cairo.PSSurface (filename, width, height)
    cr = cairo.Context (surface)

    cr.save()
    try:    
        execfile ('snippets/%s.py' % snippet, globals(), locals())
    except:
        exc_type, exc_value = sys.exc_info()[:2] 
        print exc_type, exc_value
    else:
        cr.restore()
        cr.show_page()
    
    if Verbose_mode:
        print

if __name__ == '__main__':
    if len(sys.argv) > 1 and sys.argv[1] == '-s':
        Verbose_mode=False
        del sys.argv[1]
    
    if len(sys.argv) > 1: # do specified snippets
        snippet_list = sys.argv[1:]
    else:                 # do all snippets
        snippet_list = snip_list

    for s in snippet_list:
        do_snippet (s)

Index: snippets_gtk.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/cairo_snippets/snippets_gtk.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- snippets_gtk.py	16 May 2005 01:05:28 -0000	1.7
+++ snippets_gtk.py	20 May 2005 08:57:45 -0000	1.8
@@ -62,7 +62,7 @@
         width  = da.allocation.width
         height = da.allocation.height
 
-        cr = cairo.gtk.create_cairo_context(da.window)
+        cr = cairo.gtk.gdk_cairo_create (da.window)
 
         # set window bg
         cr.set_source_rgb (*self._bg_rgb)




More information about the cairo-commit mailing list