Using latest versions of Python (2.7) and wxPython(2.8) I get the folowing error when I "PreviewText" using "HTMLEasyPrinting". In the init I have tried "parentWindow=None", "parentWindow=frame", etc. No Luck.
Does anyone have a workaround for this annoying problem. (It is documented elsewhere => "FRAME_FLOAT_ON_PARENT")
RR

C:\K>Print_Dialog.py
Traceback (most recent call last):
  File "C:\K\Print_Dialog.py", line 37, in PreviewText
    self.html_printer.PreviewText("TEXT", "doc_name")
  File "C:\K\Print_Dialog.py", line 59, in PreviewText
    HtmlEasyPrinting.PreviewText(self, self.GetHtmlText(text))
  File "C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx\html.py", line 1352, in PreviewText
    return _html.HtmlEasyPrinting_PreviewText(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion "wxAssertFailure" failed at ..\..\src\msw\toplevel.cpp(301) in wxTopLevelWindow
MSW::MSWGetParent(): wxFRAME_FLOAT_ON_PARENT but no parent?

Not without code as the error is possibly in the HtmlEasyPrinting function call.
HtmlEasyPrinting(name_of_print_object, parentWindow)
http://wxpython.org/docs/api/wx.html.HtmlEasyPrinting-class.html
which it appears you overwrote/replaced with a class of the same name but we can not tell without code.

HtmlEasyPrinting.PreviewText(self, self.GetHtmlText(text))

Here's the code I added that worked. If you use pyWiki code you get a "FRAME_FLOAT_ON_PARENT" error.
I'd love to know a better workaround.
RR

import  wx
from    wx.html import HtmlEasyPrinting


class MyFrame(wx.Frame):
   def __init__(self):
        ...
      self.TextCtrl= ...

      self.html_printer =  wx.html.HtmlEasyPrinting("Printing", self.TextCtrl)
      self.html_print = Printer()

# From the Menu "File/Page Setup" allows user to make changes in printer settings
def file_pageSetup(self, event):
    self.html_printer.PageSetup()

# From the Menu "File/Print Preview" shows how text prints before printing
def file_printPreview(self, event):
    global frame
    text = self.TextCtrl.GetValue()
    doc_name= self.filename
    self.html_printer.PreviewText(self.GetHtmlText(text), doc_name)

# From the Menu "File/Print"  actually prints the text to the printer     
def file_print(self, event):
    global frame
    text = self.TextCtrl.GetValue()
    doc_name=self.filename
    self.html_print.Print(self.GetHtmlText(text), doc_name)    

def GetErrorText():
   "Put your error text logic here.  See Python Cookbook for a useful example of error text."
   return "Some error occurred."

class Printer(HtmlEasyPrinting):
         def __init__(self):
             global frame
             HtmlEasyPrinting.__init__(self,name="Printing", parentWindow=None)

     def GetHtmlText(self,text):
         "Simple conversion of text.  Use a more powerful version"
         text = '<pre>' + text + '</pre>' # Preserve spacing
         html_text = text.replace('\n\n','<P>')     # Paragraphs
         html_text = text.replace('\n', '<BR>')     # Line breaks
         return html_text     

     def PreviewText(self, text, doc_name):
         self.SetHeader(doc_name)
         HtmlEasyPrinting.PreviewText(self, self.GetHtmlText(text))    

     def Print(self, text, doc_name):
         self.SetHeader(doc_name)
         self.PrintText(self.GetHtmlText(text),doc_name)       
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.