[pygtk] gtk.PrintOperation config
Eduardo Willians
edujurista at gmail.com
Thu Jan 10 04:21:29 WST 2008
PyFriends,
Im having problems on priting trough gtk.PrintOperation. It doesn't
print on the way it should.
Instead of printing "PRINT OUT THIS!!!!!!", its printing something like this:
"""
RINT
OUT
HIS!!!!!!
"""
Here is the code:
<code>
SETTINGS = None
def draw_page(operation, context, page_nr):
cairo_context = context.get_cairo_context()
width = context.get_width()
cairo_context.fill()
layout = context.create_pango_layout()
description = pango.FontDescription("Sans 12")
layout.set_font_description(description)
layout.set_text("\n\n\nPRINT OUT THIS!!!!!!") # Here is what it
should print out
layout.set_width(int(width))
layout.set_alignment(pango.ALIGN_CENTER)
cairo_context.show_layout(layout)
def do_print():
print_op = gtk.PrintOperation()
global SETTINGS
if SETTINGS != None:
print_op.set_print_settings(settings)
print_op.connect("draw_page", draw_page)
print_op.set_n_pages(1)
res = print_op.run(gtk.PRINT_OPERATION_ACTION_PRINT_DIALOG)
if res == gtk.PRINT_OPERATION_RESULT_APPLY:
SETTINGS = print_op.get_print_settings()
do_print()
</code>
Someone could help?
Sorry my poor english,
Thanks,
EduardoWillians
More information about the pygtk
mailing list