Sqlkit adds printing capability throught oootemplate module that in turn uses templates created with Openoffice.org and very simple syntax.
In this module ‘print’ is used in a loose way. In all situations ‘print’ means producing a printable file, it can be an .odt file or a .pdf one.
Note
In a network environment you’ll probably use a remote server that means the file will not be generated locally. Openoffice 3.1 comes with python2.6 interpreter and uno module even under Windows. So that there’s no problem using that interpreter or using a different interpreter but pointing to it’s modules.
Each sqlwidget has a printing attribute that manages printer entries that is an instance of PrintTool.
A standard way should be as easy as just setting a directory where templates should be found and adding menu entries via add_menu_entry. The default template dir is a subdir of the current directory named templates.
Templates present in this directory -if named as the nick of the sqlwidget- will be automatically added, but you will normally want to customize the context or adding variable to it or adding formatting functions (e.g. to transform numbers into monetary format), that can be easily done connecting to context-ready signal.
The default way of filling the context wraps each object into an ObjectProxy that uses Fields to present each value in a human readable format, that means also that it tries hard to follow foreign keys and substitute values retrieved by foreign key description & search field.
a print obj that is able to create a default context to handle to oootemplate
Initializes the printing tool setting a default template dir and checks for availability of module ‘uno’ from openoffice. If uno is missing the printing capabilities are made invisible.
If templates are found with the name nick.odt where the nick is the nick of the sqlwidget, entries are automatically added. This way you can generate templates and use them w/o even the need for a single line of code (unless you need to customize the context, of course)
Parameter: | master – the table or mask instance of which this is a printing tool |
---|
Add menu entry with ‘description’ using ‘template’ Both are fake printers in the sense that are ‘printer to file’
Parameters: |
|
---|
This function is meant to be overridden by a customized one
Parameter: | context – the automatically prepared oootemplate.Context. It contains 2 keys:
|
---|
You can add any keys but remember to use the correct syntax for tables (a dict with lists as <values).
This is normally used to set totals or arrange so that related table’s record are used in Tables. Read example 76.
Add to an openoffice table a list of objects wrapped in ObjProxy
Parameters: |
|
---|
A proxy that knows how to retrieve the field.human_value of attributes
context-ready: | the context has been prepared. You can connect to this signal to add element to the context.
|
---|