[wxPython-users] Some questions about printing

Jürgen Kareta python at kareta.de
Wed Aug 16 05:25:10 PDT 2006


Robin Dunn schrieb:

Hi Robin,

thanks for your replay.

> python at kareta.de wrote:
>
>> Hello all,
>>
>> I'm playing with the printframework. Some questions arrise:
>>
>> 1) I wonder if one can fetch the current settings of the default 
>> printer without
>> showing the  wx.PrintDialog and wx.PageSetupDialog ? Specially in 
>> test case it
>> is a bit tedious to show them and press ok again and again.
>
>
> I think this was discussed a month or two ago, but I can't seem to 
> find the thread right now, (probably because I need to go to sleep.)  
> Does anybody have a pointer to it?

Right, there was a topic 'Cannot print without showing the print 
dialog'. Your last answer:
"""No, you are saving a wx.PrintData object.  I think since you are not 
letting the dialog be shown then there is not a printer being selected. 
 So you need to save the wx.PrintDialogData so it can get the printer 
selection from there.  (Assuming that you used it in a print setup 
dialog.) """

It's my first try with the print framework, so mayby I miss something 
but printing is a step after fetching the PrintDialogData. I just want 
to get Instances of wxPrintDialogData and wxPageSetupDialogData filled 
with the data of the default printer, without showing and accepting the 
dialogs.


>
>>
>> 2) wx.PrintData.GetPaperId() and .GetOrientation()return integers 
>> instead of the
>> constants(stings). Can one use predefined mappings to get the more 
>> readable
>> constants ?
>
>
> For GetPaperId look at all of the wx.PAPER_* values, and 
> GetOrientation probably returns either wx.LANDSCAPE or wx.PORTRAIT.
>
I cannot confirm that (wxpy 2.6.2.1 pywin 2.4.2 on w2k sp4):

self.printerdata = wx.PrintData()
self.printerdata.SetPaperId(wx.PAPER_A4)
self.printerdata.SetOrientation(wx.PORTRAIT)
data = wx.PrintDialogData(self.printerdata)
dlg = wx.PrintDialog(self, data)
dlg.GetPrintDialogData().SetSetupDialog(True)
dlg.ShowModal();
data = dlg.GetPrintDialogData()
self.printerdata = wx.PrintData(data.GetPrintData()) # force a copy
dlg.Destroy()
print self.printerdata.GetOrientation()
returns 1 instead of wx.PORTRAIT

But anyway, how can I build a list of the wx.PAPER_* values. Should I 
type them manually or can I fetch them somewere ?


Another  question:
self.pagedata = wx.PageSetupDialogData()
dlg = wx.PageSetupDialog(self,self.pagedata)
dlg.ShowModal();
self.pagedata = dlg.GetPageSetupDialogData()
dlg.Destroy()

print self.pagedata.GetMinMarginTopLeft()
print self.pagedata.GetMinMarginBottomRight()
 
return always (0,0). Tried it with several printers. According to the 
docs this should be the minimum margins of the printer. Some hints ?







More information about the wxpython-users mailing list