Tag Archives: html

wxPrintPreview HTML on my own frame (w/o wxPreviewFrame)

I’m in the mood to dump a few code. Here’s a small code to use user’s frame, for some reason, to preview a printout.

import wx
import wx.html

sHTML = \
"""
    <h1>Hello world!</h1>
"""

class PrintPreviewFrame (wx.Frame):

  def __init__(self, *args, **kwds):
    global sHTML
    wx.Frame.__init__(self, *args, **kwds)

    self.PO = wx.html.HtmlPrintout()
    self.PO.SetStandardFonts()
    self.PO.SetMargins()

    self.PPreview = wx.PyPrintPreview(self.PO, self.PO)
    self.PreviewC = wx.PreviewCanvas(self.PPreview, self)

    self.PO.SetHtmlText(sHTML)
    self.PPreview.AdjustScrollbars(self.PreviewC)
    self.PPreview.SetCanvas(self.PreviewC)
  ####
####


app = wx.PySimpleApp()
frm = PrintPreviewFrame(None)
frm.Show()
app.MainLoop()

*shiver*

Advertisements

Leave a comment

Filed under Ilmu