wxRichTextPrinting Preview

I'm continuing to make good progress with the wxRichTextCtrl. This morning,
I decided to look into printing issues. So far, so good. It's pretty
simple. Here's my OnPrint code:

      rtp = richtext.RichTextPrinting("Print test")
      buf = self.txtCtrl.GetBuffer()
      rtp.PrintBuffer(buf)

Works perfectly.

But I'd like to do a Print Preview. When I replace PrintBuffer(buf) with
PreviewBuffer(buf), the program crashes with an unhandled exception error
message on Windows. On OS X, it shows a print preview window of my first
page, but if I try to go to the next page, I get a crash saying the program
quit unexpectedly. I've also tried PreviewFile(), but nothing at all
happens when I call that on either platform.

Any ideas what I might be doing wrong here?

David K. Woods, Ph.D.
Researcher, Transana Lead Developer
Wisconsin Center for Education Research
University of Wisconsin, Madison
http://www.transana.org

PreviewBuffer seems to be working fine in my current 2.8 workspace, so I'm guessing that there was a bug on the C++ side that has been fixed. It looks like there is going to be a 2.8.11 release in a couple weeks, so I'll try to get a wxPython build out around the same time.

···

On 1/28/10 9:47 AM, David wrote:

I'm continuing to make good progress with the wxRichTextCtrl. This morning,
I decided to look into printing issues. So far, so good. It's pretty
simple. Here's my OnPrint code:

       rtp = richtext.RichTextPrinting("Print test")
       buf = self.txtCtrl.GetBuffer()
       rtp.PrintBuffer(buf)

Works perfectly.

But I'd like to do a Print Preview. When I replace PrintBuffer(buf) with
PreviewBuffer(buf), the program crashes with an unhandled exception error
message on Windows. On OS X, it shows a print preview window of my first
page, but if I try to go to the next page, I get a crash saying the program
quit unexpectedly. I've also tried PreviewFile(), but nothing at all
happens when I call that on either platform.

Any ideas what I might be doing wrong here?

--
Robin Dunn
Software Craftsman

Hi,

(Sorry for my english : i'm french)

I've spend time today on richTextCtrl's preview. I don't know if this
code will help you but that's what i've done :

    def Preview(self):
        printout1 = wx.richtext.RichTextPrintout()
        printout1.SetRichTextBuffer(self.rtc.GetBuffer())
        printout2 = wx.richtext.RichTextPrintout()
        printout2.SetRichTextBuffer(self.rtc.GetBuffer())
        data = wx.PrintDialogData()
        data.SetAllPages(True)
        data.SetCollate(True)
        datapr = wx.PrintData()
        data.SetPrintData(datapr)
        # Impression
        preview = wx.PrintPreview(printout1, printout2, data)
        if not preview.Ok():
            print "Probleme dans le preview du richTextCtrl."
            return
        pfrm = wx.PreviewFrame(preview, self, u"Aperçu avant
impression")
        pfrm.Initialize()
        pfrm.SetPosition(self.GetPosition())
        pfrm.SetSize(self.GetSize())
        pfrm.Show(True)

with that the unhandled exception error disapperas for me.

Good luck

David i've seen your RTFParser : Thx for your good work !