[wxPython-dev] 20060902 test build uploaded
jmf
jfauth at bluewin.ch
Thu Sep 14 06:34:51 PDT 2006
Some feedback about this printing stuff.
Your proposal to use PDFCreator was an excellent idea. It helped
me a lot to understand the underlaying machanism.
"Grimms' tale example"
def OnPrint(self, evt):
data = wx.PrintDialogData(self.pdata)
printer = wx.Printer(data)
text = self.tc.GetValue()
printout = TextDocPrintout(text, "title", self.margins)
useSetupDialog = True
#~ useSetupDialog = False
if not printer.Print(self, printout, useSetupDialog) \
and printer.GetLastError() == wx.PRINTER_ERROR:
wx.MessageBox(
"There was a problem printing.\n"
"Perhaps your current printer is not set correctly?",
"Printing Error", wx.OK)
else:
data = printer.GetPrintDialogData()
self.pdata = wx.PrintData(data.GetPrintData()) # force a copy
printout.Destroy()
The printing rules have changed in wxPy2.7:
1) Define some printdata.
2) Define a print job, printout.
3) Create an instance of wx.Printer.
4) Launch the print process, with a <wx.Printer>.print(...).
This is the tricky part. wxWidgets/wxPython with the help of the
installed printing drivers will build a setup dialog window with a "print
button" and the user will print from there.
The previously defined printdata are not used for the real printing job,
but are used in the display (and the setup) of the setup dialog.
5) Launch the print with the print button.
At this time, it seems the real printing is using some "other internal
printdata" from this setup dialog window. Indeed, it is still possible
to modify the printing setup, like orientation, resolution, ... (The
PDFCreator was a big help).
This two-step process is a nice design. It let the user choose the
printer and define the print options.
The negative side effect of this approach: it seems impossible to
have a direct printing, bypassing the setup dialog and using the
default printer. If, in the above example, I set useSetupDialog = False,
printing will not work - nothing will be printed, though some printing
job is realised, I get the small printer icon on my taskbar - at least
on my platform (w2k).
I'm not complaining to much. I do not know if this is a real bug or if
it is by design. So far, I did not find any example with an useSetupDialg
= False. Let see what other wxPython users think about this.
Previewing is a different task.
Regards.
Jean-Michel Fauth, Switzerland
More information about the wxpython-dev
mailing list