Problem setting printer destination

Hi all,

I would like to print from wxPython to a known printer destination.
I modified the example in "wxPython in Action" as follows:

    def OnPrint(self, evt):
        self.pdata.SetPrinterName (u"CUPS-PDF") # added fixed printer
destination
        data = wx.PrintDialogData(self.pdata)
        printer = wx.Printer(data)
        text = self.tc.GetValue()
        printout = TextDocPrintout(text, "title", self.margins)
        useSetupDialog = False # no dialog needed
        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()

Unfortunately, wxPython is not using the selected printer.
Can you help?

Cheerio
Peter

Is that the same string as what gets put into self.pdata if you select that printer in the print dialog?

···

On 1/30/11 12:06 PM, Peter Fankh�nel wrote:

Hi all,

I would like to print from wxPython to a known printer destination.
I modified the example in "wxPython in Action" as follows:

     def OnPrint(self, evt):
         self.pdata.SetPrinterName (u"CUPS-PDF") # added fixed printer
destination

--
Robin Dunn
Software Craftsman

Hi Robin,

yes that's the same string.

In today I found, what's missing:
self.pdata.SetToPage (2)
If that is added, the program works.
I got the idea from PrintFramework.py in the wxPython samples 2.9.1.1.

Thanks for your help.

Cheerio
Peter

···

On Jan 31, 6:49 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 1/30/11 12:06 PM, Peter Fankh nel wrote:

> Hi all,

> I would like to print from wxPython to a known printer destination.
> I modified the example in "wxPython in Action" as follows:

> def OnPrint(self, evt):
> self.pdata.SetPrinterName (u"CUPS-PDF") # added fixed printer
> destination

Is that the same string as what gets put into self.pdata if you select
that printer in the print dialog?

--
Robin Dunn
Software Craftsmanhttp://wxPython.org