On Friday 27 March 2009 11:28:58 am johnf wrote:
> On Friday 27 March 2009 10:54:28 am Paul McNett wrote:
> > Here's a working test:
> >
> > {{{
> > import wx
> > a = wx.App(False)
> >
> > def testPrint():
> > data = wx.PrintDialogData()
> > data.EnableSelection(True)
> > data.EnablePrintToFile(True)
> > data.EnablePageNumbers(True)
> > data.SetMinPage(1)
> > data.SetMaxPage(5)
> > data.SetAllPages(True)
> >
> > dlg = wx.PrintDialog(None, data)
> >
> > result = dlg.ShowModal()
> > print result, result == wx.ID_OK
> > if result == wx.ID_OK:
> > data = dlg.GetPrintDialogData()
> > mytest=data.GetPrintData()
> > print mytest.GetPrinterName()
> >
> > dlg.Destroy()
> >
> > testPrint()
> > }}}
> >
> > No printer name on Mac.
> >
> > Paul
>
> That's to bad. I was hoping that the printer name could be retrieved.
>
> Here's my thinking.
>
> Since I believe that printing PDF's are now universal (tested printing on
> windows and linux - I hope MAC's work the same way)
>
> if sys.platform == 'win32':
> os.system('print '+filenamewithpath)
> elif sys.platform == 'linux2':
> prnstr = 'lp -d %s %s' % (printername filenamewithpath)
> os.system(prnstr)
> else: ##Must be a MAC
> os.system(string using what a MAC needs)
>
> If the above worked then we would have a universal way to print PDF's from
> within report writer. I'm not sure if os.system would be the best (maybe
> popen() ) but you get the general idea.
>
> Under Linux (also available on the MAC) there is pycups.py. Which uses the
> CUPS lib to retrieve information on the printer queue. But is not part of
> the standard available packages. To be honest I don't even know if MAC's
> use CUPS to print.
>
> import cups
> c = cups.Connection()
> printers = c.getPrinters()
>
> Now with the list of printers. We create a dialog to select the printer
> and pass the selection to the above print routine.
>
> On the surface it appears simple. As you can see we could print the PDF's
> generated from report writer and not just depend on forcing a preview to
> allow printing.
The MAC has 'lp' too. Paul, could you test and see if you are able print a
PDF using os.system(lp something).
--
John Fabiani
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message:
http://leafe.com/archives/byMID/[email protected]