[PyKDE] Printing using QPrinter
kibab at icehouse.net
Fri Mar 3 04:07:52 GMT 2006
As long as it is going to be fairly simple, you could use QSimpleRichText
(alsuming Qt3). It allows for basic html-like styling and tables. It's kind
of picky and the html support isn't well documented (well, there are a number
of things that are available though not documented). You can actually set up
fairly complicated pages using this process, but it does take some work.
Just something to think about.
On Wednesday 01 March 2006 2:49 pm, Fabian Steiner wrote:
> I am currently working on an application where the user is able to
> create new worksheets and to delete existing ones. All of these
> worksheets have the same structure, only some values should be changed.
> A minimal example would be something like this:
> Name: ........... Date: ..............
> Role: ............ Departure: ..............
> Address: ............
> (about 20 other items ...)
> The values are stored in a SQLite database. Now I would like to offer
> the possibility to print out a single record on a DinA4 paper. In order
> to do this, the dots (...) above of course have to be replaced by the
> current record's values and the different parts have to fit on one page.
> Some values should also be shown in tables and lists, so one may speak
> of a quite complex layout.
> This is what I have so far:
> app = QApplication(sys.argv)
> printer = QPrinter(QPrinter.PrinterResolution)
> if printer.setup():
> painter = QPainter(printer)
> metrics = QPaintDeviceMetrics(painter.device())
> marginHeight = 6
> marginWidth = 8
> body = QRect(marginWidth, marginHeight, metrics.width() - 2 *
> marginWidth, metrics.height() - 2 * marginHeight) painter.drawRect(body)
> body is the border of the whole page, the other objects should be placed
> in it, but I don't know how to position the other elements. Of course, I
> can pass the appropriate x, y values to QPainter.drawText(), but it
> means a lot of work to get them for about 25 elements.
> Is there any other way to realize my purpose?
> Thank you for any input!
> Fabian Steiner
> PyKDE mailing list PyKDE at mats.imk.fraunhofer.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 191 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20060303/c1c8a808/attachment.bin
More information about the PyQt