Still have print problem

I still have this printing problem from a while ago. The problem does not
appear in my other applications:

The Demo, on my system has the same problem. The Print Dialog has the A4
paper type already selected in wxPrintDialog. I am not sure why, because on
the operating system's printer settings, it is set to "letter". I noticed
that it can be explicitly set in the data obtained from the
wxPageSetupDialog though, but it doesn't save. I have tried the following
code and it changes back to A4 when in the Print Dialog (The Default paper
ID also changes back to A4 when using wxPrintDialog from the Demo. I am
using the HTMLEasyPrinting method shown at
<http://wiki.wxpython.org/index.cgi/Printing>
http://wiki.wxpython.org/index.cgi/Printing):

   data = wxPageSetupDialogData()
        data.SetMarginTopLeft( (15, 15) )
        data.SetMarginBottomRight( (15, 15) )
        data.SetPaperId(wxPAPER_LETTER)
                               
        dlg = wxPageSetupDialog(self, data)
        if dlg.ShowModal() == wxID_OK:
            data = dlg.GetPageSetupData()
            tl = data.GetMarginTopLeft()
            br = data.GetMarginBottomRight()
            print 'Margins are: %s %s\n' % (str(tl), str(br))
        dlg.Destroy()
        
        self.printer.Print(string, " Financial Scenario")

Henry Grantham wrote:

I still have this printing problem from a while ago. The problem does not
appear in my other applications:
The Demo, on my system has the same problem. The Print Dialog has the A4
paper type already selected in wxPrintDialog. I am not sure why, because on
the operating system's printer settings, it is set to "letter". I noticed
that it can be explicitly set in the data obtained from the
wxPageSetupDialog though, but it doesn't save. I have tried the following
code and it changes back to A4 when in the Print Dialog (The Default paper
ID also changes back to A4 when using wxPrintDialog from the Demo. I am
using the HTMLEasyPrinting method shown at
<http://wiki.wxpython.org/index.cgi/Printing&gt;
http://wiki.wxpython.org/index.cgi/Printing):

        data.SetMarginTopLeft( (15, 15) )
        data.SetMarginBottomRight( (15, 15) )
        data.SetPaperId(wxPAPER_LETTER)
                                       dlg = wxPageSetupDialog(self, data)
        if dlg.ShowModal() == wxID_OK:
            data = dlg.GetPageSetupData()
            tl = data.GetMarginTopLeft()
            br = data.GetMarginBottomRight()
            print 'Margins are: %s %s\n' % (str(tl), str(br))
        dlg.Destroy()
                self.printer.Print(string, " Financial Scenario")

If you are using the HTMLEasyPrinting then you need to use the PrintData that it is using internally. The above code does not set those values globally, only for that instance of wx.PageSetupDialogData (and the wx.PrintData that it has within it.) If using the normal Print Framework then you would pass that data on to the wx.Printout. But since HTMLEasyPrinting already has the data objects you can do it like this:

  self.printer.GetPrintData().SetPaperId(wx.PAPER_LETTER)
  self.printer.PrintText(myHtmlText)

···

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