On Fri, May 25, 2007 at 16:22:18 +0200, Gian Mario Tagliaretti wrote:
>2007/5/25, Magnus Therning <[EMAIL PROTECTED]>:
>>What I'd like to do is very simple, just send the contents of a string,
>>prepared in a Python script, to the printer.  If possible I'd like to
>>use the GNOME printing thingamajig rather than just throwing it in a
>>file and sending lpr on it.  I can't seem to find any documention on how
>>to work with printing in GNOME though.  Can anyone offer me some good
>>pointers?
>>
>
>in pygtk you can use the new gtk.Print* stuff, documented with the
>rest of pygtk in the reference manual:
>http://www.pygtk.org/docs/pygtk/index.html
>
>the old gnome print stuff is documented as well:
>http://www.pygtk.org/pygnomeprint/index.html

Thanks for the pointers.  However this turns out to be a little more
complicated than I had hoped :-(

This is what I have so far, but it prints one blank page:

    def print_text(text):
        p = gtk.PrintOperation()
        
        p.connect("begin-print", begin_print)
        p.connect("draw-page", draw_page)
    
        r = p.run(gtk.PRINT_OPERATION_ACTION_PRINT_DIALOG)
    
        print r
    
    
    def begin_print(op, ctx):
        op.set_n_pages(1)
    
    
    def draw_page(op, ctx, page_nr):
        cairo_ctx = ctx.get_cairo_context()
    
        layout = cairo_ctx.create_layout()
        layout.set_text('Some text'.decode('utf8'))
        desc = pango.FontDescription("sans 28")
        layout.set_font_description(desc)
    
        cairo_ctx.move_to(30, 30)
        cairo_ctx.layout_path(layout)
    
    
    print_text()

Any more pointers?

/M

-- 
Magnus Therning                             (OpenPGP: 0xAB4DFBA4)
[EMAIL PROTECTED]             Jabber: [EMAIL PROTECTED]
http://therning.org/magnus

Software is not manufactured, it is something you write and publish.
Keep Europe free from software patents, we do not want censorship
by patent law on written works.

The day after tomorrow is the third day of the rest of your life.

Attachment: pgp1lJ056ojQy.pgp
Description: PGP signature

_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to