[PyQt] Page setup for printer defaults

Robert Norman tfcrobert at gmail.com
Sat Jun 20 01:41:21 BST 2009

Hi Olivier,

I am running on Windows XP and I've used some Win32 Stuff -- I have 
"Python programming on Win32" and use it as a reference from time to 
time. I'll look at the Print stuff you pointed out but had hoped that 
QPrinter could handle it.  I suppose it's difficult to handle cross 
platform with so many different printers and printer options. I even 
tried cpickle but of course it can't  pickle this class.

Still hopeful....


Olivier Fournier wrote:
> Robert Norman a écrit :
>> Hello PyQt group,
>> My application uses a Brother label printer to spit out labels. I'd 
>> like to do a "Page Setup", say in my preferences dialog and then save 
>> the printer information in a settings so that we don't have to go 
>> through a print dialog.
>> Currently I go through the print dialog once then use the resulting 
>> QPrinter for subsequent print operations and that works fine. I can 
>> assign the printer name to QPrinter so that it at least defaults to 
>> the correct printer, but I'm having trouble figuring out how to set 
>> the appropriate variables to match the printer to the specific label 
>> size.
>> Specifically, in the print dialog, I use the properties dialog to 
>> select the label size. On return I can examine things like pageSize, 
>> pageRect, paperSize, paperRect but I can't seem to set pageSize and 
>> can't find methods for setting the  page or paper Rect.
>> For example, after the print dialog, pageSize returns 30 but 
>> setPageSize(30) causes an invalid  type error since it expects a 
>> QPrinter.PageSize enum value. 1) How would you go about doing a 
>> PageSetup dialog, not Print Dialog, to both select a printer and it's 
>> default properties.
>> 2) What needs to be saved and how can I restore the relevant properties.
>> I'm used to working through these issues myself, an often find that 
>> once the question is asked, the answer seems to come on it's own, but 
>> this time I'm stuck.
>> Thanks
>> _______________________________________________
>> PyQt mailing list    PyQt at riverbankcomputing.com
>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> hi,
> if your application run with Windows XP, you can use win32 api.
> you can find sample here: http://www.speechcomputing.com/node/2271
> regards
> olivier fournier

More information about the PyQt mailing list