Okay, last thing from me for now. Let you digest these first.
Oh forgot something. If start up in a terminal so you can see errors. If you
change anything in the printdialog you get these errors:
david@decibels ~/temp4 $ python printtest.py
(python:575): GLib-GObject-WARNING **: invalid (NULL) pointer instance
(python:575): GLib-GObject-CRITICAL **: g_signal_connect_data: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed
Here is the sample I worked up with wxGlade real quick. Wasn't going
to post it, but it would be a quick demo of the errors.
NOTE: also, this might be fixed in the most recent version of wxGTK.
wxPython release was done before some more fixes. Will have to
test them out.
Just change the printout to some html on your system:
<code>
#!/usr/bin/env python
import wxversion
wxversion.select("2.8")
import wx
import wx.html as html
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.htmlwin = wx.html.HtmlWindow(self, -1,size=((400,200)))
self.pbutton = wx.Button(self, -1, "Print")
self.__set_properties()
self.__do_layout()
# setup printing
self.printer = html.HtmlEasyPrinting()
# button
self.Bind(wx.EVT_BUTTON, self.OnPrint,id=-1)
def __set_properties(self):
self.SetTitle("frame_1")
def __do_layout(self):
sizer_2 = wx.BoxSizer(wx.VERTICAL)
sizer_2.Add(self.htmlwin, 1, wx.EXPAND, 0)
sizer_2.Add(self.pbutton, 0, 0, 0)
self.SetSizer(sizer_2)
sizer_2.Fit(self)
self.Layout()
def OnPrint(self, event):
self.printer.GetPrintData().SetPaperId(wx.PAPER_LEGAL)
self.printer.GetPrintData().SetOrientation(wx.LANDSCAPE)
self.printer.GetPageSetupData().SetMarginTopLeft((10,10))
self.printer.GetPageSetupData().SetMarginBottomRight((10,10))
#linux
self.printer.PreviewFile("StatusReports.html")
#self.printer.PrintFile(self.html.GetOpenedPage())
if __name__ == "__main__":
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
frame_1 = MyFrame(None, -1, "")
app.SetTopWindow(frame_1)
frame_1.Show()
app.MainLoop()
<end code>