wx.html.printing problem

This code gets a nasty error.

import wx
import wx.html

Ozy="""<html ><head></head><body>
Ozymandias - I met a traveler from an antique land<br>
Who said two vast and trunkless legs of stone<br>
</body></html>"""

app = wx.PySimpleApp()
wxprt = wx.html.HtmlEasyPrinting('Printing', None)
wxprt.PreviewText(Ozy)
##wxprt.PreviewFile("c:\pje\ozy.html")

Here's the error ...

wx._core.PyAssertionError: C++ assertion "wxAssertFailure at
..\..\..src\msw\toplevel.cpp(301) in
wxTopLevelWindowMST::MSWGetParent() : wxFRAME_FLOAT_ON_PARENT but no
parent?

Has anyone else seen anything else like this? Any clues?

Kind regards

Phil

Hi,

This code gets a nasty error.

import wx
import wx.html

Ozy="""<html ><head></head><body>
Ozymandias - I met a traveler from an antique land<br>
Who said two vast and trunkless legs of stone<br>
</body></html>"""

app = wx.PySimpleApp()
wxprt = wx.html.HtmlEasyPrinting('Printing', None)
wxprt.PreviewText(Ozy)
##wxprt.PreviewFile("c:\pje\ozy.html")

Here's the error ...

wx._core.PyAssertionError: C++ assertion "wxAssertFailure at
..\..\..src\msw\toplevel.cpp(301) in
wxTopLevelWindowMST::MSWGetParent() : wxFRAME_FLOAT_ON_PARENT but no
parent?

Has anyone else seen anything else like this? Any clues?

The error is an Assertion error, assertions are used as warnings to
tell the programmer that they are doing something wrong. It says the
window is using a style that requires it to have a Parent window. You
created your HtmlEasyPrinting object by specifying None to the
parentWindow argument, it needs to have a parent window assigned to
it.

app = wx.PySimpleApp()
frame = wx.Frame(None)
wxprt = wx.html.HtmlEasyPrinting('Printing', frame)
wxprt.PreviewText(Ozy)
app.MainLoop()

Cody

···

On Wed, Jun 23, 2010 at 1:42 PM, Philip Ellis <philipjellis@gmail.com> wrote:

Cody
Thank you very much for this. I have a couple of comments.
1) All my users and I are convinced that this was working perfectly
until a few weeks ago, when I recreate the .exes. I wonder how it
managed to work coded like that?
2) I think p495 of the wxPython in Action book is a bit misleading.
The example given has 'parentWindow=None' in it and the accompanying
text led me to think that the parentWindow was not an important field.

Having said all that, I will keep an eye open for this in future.
Thanks again.
rgds
phil

···

On Jun 24, 8:32 am, Cody Precord <codyprec...@gmail.com> wrote:

Hi,

On Wed, Jun 23, 2010 at 1:42 PM, Philip Ellis <philipjel...@gmail.com> wrote:
> This code gets a nasty error.

> import wx
> import wx.html

> Ozy="""<html ><head></head><body>
> Ozymandias - I met a traveler from an antique land<br>
> Who said two vast and trunkless legs of stone<br>
> </body></html>"""

> app = wx.PySimpleApp()
> wxprt = wx.html.HtmlEasyPrinting('Printing', None)
> wxprt.PreviewText(Ozy)
> ##wxprt.PreviewFile("c:\pje\ozy.html")

> Here's the error ...

> wx._core.PyAssertionError: C++ assertion "wxAssertFailure at
> ..\..\..src\msw\toplevel.cpp(301) in
> wxTopLevelWindowMST::MSWGetParent() : wxFRAME_FLOAT_ON_PARENT but no
> parent?

> Has anyone else seen anything else like this? Any clues?

The error is an Assertion error, assertions are used as warnings to
tell the programmer that they are doing something wrong. It says the
window is using a style that requires it to have a Parent window. You
created your HtmlEasyPrinting object by specifying None to the
parentWindow argument, it needs to have a parent window assigned to
it.

app = wx.PySimpleApp()
frame = wx.Frame(None)
wxprt = wx.html.HtmlEasyPrinting('Printing', frame)
wxprt.PreviewText(Ozy)
app.MainLoop()

Cody

Hello,

Cody
Thank you very much for this. I have a couple of comments.
1) All my users and I are convinced that this was working perfectly
until a few weeks ago, when I recreate the .exes. I wonder how it
managed to work coded like that?

I haven't looked to see if anything has changed but its possible that
the style flags for the dialog that the html easy print uses may have
changed in recent releases or that the assert in the toplevel window
class was previously not there.

2) I think p495 of the wxPython in Action book is a bit misleading.
The example given has 'parentWindow=None' in it and the accompanying
text led me to think that the parentWindow was not an important field.

I agree that it is misleading, if it is a required parameter it should
not be specified as a keyword param unless it is there to maintain
compatibility with earlier versions of the class that didn't require a
parent window.

Cody

···

On Thu, Jun 24, 2010 at 12:36 PM, Philip Ellis <philipjellis@gmail.com> wrote:

Cody
Thank you very much for this. I have a couple of comments.
1) All my users and I are convinced that this was working perfectly
until a few weeks ago, when I recreate the .exes. I wonder how it
managed to work coded like that?

Were you using a different version then?

2) I think p495 of the wxPython in Action book is a bit misleading.
The example given has 'parentWindow=None' in it and the accompanying
text led me to think that the parentWindow was not an important field.

Keep in mind that the book is over 4 years old now, which is almost an eternity in the tech world. Most things in the book are still correct but little details will certainly be changing over time. In this case I expect that either the float on parent style for the print preview window or the assert was added recently. BTW, the wx C++ docs also still indicate that not passing a parent window is ok...

···

On 6/24/10 10:36 AM, Philip Ellis wrote:

--
Robin Dunn
Software Craftsman

What error? What version and platform? MakingSampleApps - wxPyWiki

···

On 9/8/12 12:48 PM, abhishek singh wrote:

Hi Cody,

I am also getting this error. How to fix this , If I am using multiple
panel , single frame program. My Printer class is as below :-

class Printer(HtmlEasyPrinting):
     def __init__(self):
         HtmlEasyPrinting.__init__(self)

     def Print(self, text):

         self.PrintText(text)

     def PreviewText(self, text):

     HtmlEasyPrinting.PreviewText(self, text)

And then in another class I am calling PreviewText

     def onButton(self,event):

         UserText = self.UserName.GetValue()
         AmtText = self.Amount.GetValue()
         text = "MG <space> %s#%s" % (UserText,AmtText)
         p = Printer()
         p.PreviewText(text)

When I click the Preview button in my frame it does show the preview
text as desired but also throws this error.

My main is as below -----

if __name__ == "__main__":
     app = wx.App()
     MainFrame().Show()
     app.MainLoop()

--
Robin Dunn
Software Craftsman