Some questions about printing

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.

2) wx.PrintData.GetPaperId() and .GetOrientation()return integers instead of the
constants(stings). Can one use predefined mappings to get the more readable
constants ?

Thanks in advance
Jürgen

···

-------------------------------------------------
Versandt durch den Webmaildienst der LDC GmbH Bonn

python@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?

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.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn schrieb:

Hi Robin,

thanks for your replay.

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 ?

···

python@kareta.de wrote:

Jürgen Kareta wrote:

Robin Dunn schrieb:

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.

There isn't a way to get all the values filled in from the printer defaults, but if you just set the values you want to set and leave the rest alone, then the defaults should be used when you print.

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

wx.PORTRAIT is 1. wx.LANDSCAPE is 2.

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

[x for x in dir(wx) if x.startswith('PAPER_')]

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 ?

No, it is the minimum margin that the user is allowed to enter on the page setup dialog, not the min allowed by the printer. To get what was actually entered use GetMarginTopLeft and GetMarginBottomRight.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Zitat von Robin Dunn <robin@alldunn.com>:
Get it. Thanks a lot.

···

Jürgen Kareta wrote:
> Robin Dunn schrieb:

>> 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.

There isn't a way to get all the values filled in from the printer
defaults, but if you just set the values you want to set and leave the
rest alone, then the defaults should be used when you print.

>>> 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

wx.PORTRAIT is 1. wx.LANDSCAPE is 2.

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

[x for x in dir(wx) if x.startswith('PAPER_')]

> 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 ?

No, it is the minimum margin that the user is allowed to enter on the
page setup dialog, not the min allowed by the printer. To get what was
actually entered use GetMarginTopLeft and GetMarginBottomRight.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

-------------------------------------------------
Versandt durch den Webmaildienst der LDC GmbH Bonn