|
From: Kevin A. <al...@se...> - 2002-01-18 20:18:48
|
I just did the following test from the Shell using the simpleBrowser sample and it worked correctly under Windows and Cliff confirmed that it works under Linux, so I think we have a simple cross-platform solution for printing in the form of a wrapped wxHtmlEasyPrinting class. simpleBrowser.py -s # this opens to the diveintopython site Then I opened the docs/html/index.html file of PythonCardPrototype, though you should be able to use any URL or text. Then in the shell I did: >>> from wxPython import wx >>> source = comp.htmlDisplay._delegate.GetParser().GetSource() >>> base = comp.htmlDisplay._delegate.GetParser().GetFS().GetPath() >>> base 'C:/python/PythonCardPrototype/docs/html/' >>> from wxPython import html >>> p = html.wxHtmlEasyPrinting() >>> p.PrintText(source, base) This brought up a print dialog and I clicked okay. With a few utility wrappers, this should let us easily print anything that wxWindows can display: plain text files, formatted files using the limited set of HTML available to us, images, etc. without worrying about platform differences. We can support the more elaborate wxPython printing methods as well for better font support, but this will get us started. Note that the Python Powered GIF (http://webware.sourceforge.net/PythonPowered.gif) doesn't show up if you open index.html because of the Host: header not being sent in the current wxHTTP class, that is supposedly fixed in wxWindows cvs and will work in wxPython 2.3.3. If you want to experiment on your own, look at the wxHTML notes in the wxWindows documentation for more information about specific classes and methods. ka |