wxHtmlPrintout Questions

Hello everyone.

Does anyone here have any experience using wxHtmlPrintout? I am writing
an application that uses a subclass of this class. I subclassed it according
to what was described in the documentation. The required methods have
been overridden in the subclass as follows:

def OnBeginDocument(self, start, end):
  return self.base_OnBeginDocument(start, end)

def OnEndDocument(self):
  self.base_OnEndDocument()

def OnBeginPrinting(self):
  self.base_OnBeginPrinting()

def OnEndPrinting(self):
  self.base_OnEndPrinting()

def OnPreparePrinting(self):
  self.base_OnPreparePrinting()

def HasPage(self, page):
  if page <= self.__page_count:
    return True
  else:
    return False

def GetPageInfo(self):
  return (1, self.__page_count, 1, self.__page_count)

def OnPrintPage(self, page):
  self.SetHtmlText(self.compose_html_for_page(page))
  return wxHtmlPrintout.OnPrintPage(self, page)

I am using wxHtmlPrintout subclass because I need to have it generate
new HTML document each time a page is printed. That is, I can store the
data needed for the pages in an array, one element for each page, each
element containing data that compose_html_for_page() requires for a
given page. The preview window displays, but there is no text. I have it
echo the generated HTML to stdout, no errors in the HTML. I tried
putting "tracers" inside the overridden methods, it seems that they are
not getting called by the print framework. eg, the overridden
OnPrintPage() method in the subclass is not being called. I used the
code in the wxPYthon samples for PrintFramework as the basis for my
own code. But the PrintFramework sample derives directly from
wxPrintout, and not wxHtmlPrintout. I read the docs and it says
wxHtmlPrintout is derived from wxPrintout. I gather if I subclass
wxHtmlPrintout I can create a new class that behaves differently when
OnPrintPage is called. But it seems it does not work that way.

Anyone have any ideas on how to go about deriving from wxHtmlPrintout
"properly"?

Incidentally, I also tried deriving from wxPrintout and used
wxHtmlDCRenderer() to render the HTML on the printout's DC. No such
luck, no HTML text output and Render() returns zero. Plus it does not
work under wxGTK.

Other ideas are also welcome. I just wanted to have a convenient way of
printing out formatted and laid out documents (with possibility of
including graphics), which is why I used wxHtmlPrintout (and the
wxHtmlDCRenderer inside a wxPrintout subclass).

My software versions:

Windoze98 - wxPython 2.4.0.6 under Python 2.2.2
Linux - wxPython 2.4.1.2 under Python 2.2.2

···

--
Public Key here:

http://abingfamily.net/~nimrod/nimrod_at_abingfamily_dot_net.asc

Key expires 2004-06-03

Nimrod A. Abing wrote:

Hello everyone.

Does anyone here have any experience using wxHtmlPrintout?

Try using wxHtmlEasyPrinting instead.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

wxHtmlEasyPrinting won't do since I require more functionality than it
provides out-of-the-box. Anyway, I have managed to get the behavior I
wanted by subclassing wxPrintout and using code from wxHtmlPrintout
(based on the C++ source). I used wxHtmlDCRenderer under the hood to
implement the desired behavior which was:

1. Take an array, with the elements containing an associative array that
   contains the data for each page.

2. When OnPrintPage is called, retrieve the data for the given page from
   the array and pass it to an internal method to create an HTML
   document. Use the created HTML document to SetHtmlText() the
   wxHtmlDCRenderer and then Render() to the DC of the printout object.

Each page here is a *complete* HTML document, not just a part/fragment
of a bigger one. This was the desired behavior I wanted, it's kind of
weird I know but it was better than having to write my own code to
render the individual pages.

For the curious, the application I am writing prints out prescriptions,
hence the odd behavior that I required from wxHtmlPrintout. Each
prescription has to be on a separate page generated as a complete HTML
document using a preformed HTML template.

Just a question, why didn't subclassing wxHtmlPrintout work? I did
override the methods that needed to be overridden as said in the docs. I
am saying it doesn't work because the overridden methods do not seem to
get called. What is the correct way to subclass it? Am I missing
something?

Best regards and thank you.

···

Robin Dunn <robin@alldunn.com> wrote:

Nimrod A. Abing wrote:
>Hello everyone.
>
>Does anyone here have any experience using wxHtmlPrintout?

Try using wxHtmlEasyPrinting instead.

--
_nimrod_a_abing_

PGP Public Key here:

http://abingfamily.net/~nimrod/nimrod_at_abingfamily_dot_net.asc

Key expires 2004-06-03

Dear all,

if found some older messages concerning the following topic in the archives,
but I did not found an answer:

When integrating the Acrobat PDF control (as demonstrated in the wxPython
demos)
in an app, resizing the parent frame/panel causes the control to flicker and
(sometimes)
it will even not being repainted as well as moving other windows over it
causes the content
damaged.

Is there any solution to fix this behaviour ?
Possibly using the underlying PyCWND object ?

Thanks in advance,

Hannes Grund

Nimrod A. Abing wrote:

Just a question, why didn't subclassing wxHtmlPrintout work? I did
override the methods that needed to be overridden as said in the docs. I
am saying it doesn't work because the overridden methods do not seem to
get called. What is the correct way to subclass it? Am I missing
something?

No. In order to support overriding virtual C++ methods with Python methods in a derived class I have to add some special code to the wrappers. But it adds some overhead even when it is not being used so I try to use it sparingly, usually only in the classes that are the generic base classes not the C++ specializations...

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!