1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
"""printing/preparing Context
You can customize the context you pass to the PrintTool eather subclassing
and overriding prepare_context or connecting to signal 'context-ready'
"""
from sqlkit.misc.printing import PrintTool
class MyPrinter(PrintTool):
def prepare_context(self, context):
"""
substitue director's films as table objects
"""
context.translate['d'] = 'director'
context.translate['nation'] = 'director.nation'
return context
t = SqlTable(model.Movie, dbproxy=db)
t.printing = MyPrinter(t)
t.printing.add_menu_entry('Print to pdf', 'movies-translate.odt', mode='pdf',
accel="<alt>p",
tip="Generate a pdf file with these movies")
t.printing.add_menu_entry('Print to odt', 'movies-translate.odt', mode='odt',
tip="Generate an odt file with these movies")
t.reload()
|