[wxPython] Print text from wxTextCtrl using PrintFramework

Date: Wed, 24 Apr 2002 08:24:43 -0700 (PDT)
From: DJ Webre <d_webre@yahoo.com>
Subject: Fwd: Print text from wxTextCtrl using PrintFramework
To: wxpython-users <wxpython-users@lists.wxwindows.org>

> Date: Tue, 23 Apr 2002 15:15:57 -0700 (PDT)
> From: DJ Webre <d_webre@yahoo.com>
> Subject: Print text from wxTextCtrl using PrintFramework
> To: wxpython-users <wxpython-users@lists.wxwindows.org>
>
> I am trying to print from wxTextCtrl using PrintFramework as
> suggested
> by Robin Dunn on Jul 3, 2001 (Question about the PrintFramework).
>
> The following code gives me an error
>
> AttributeError: MainWindow instance has no attribute 'canvas'.
>
> Any assistance is appreciated.
> ____________________________

24 Apr 2002

Based on Robin Dunn's comment, I changed my code as follows:

def OnFilePrint(self, evt): # Print
         prntxtctrl = PrintFramework.MyPrintout(self,
             self.control.GetValue())
         self.printData = wxPrintData()
         self.printData.SetPaperId(wxPAPER_LETTER)
         pdd = wxPrintDialogData()
         pdd.SetPrintData(self.printData)
         printer = wxPrinter(pdd)
  ==> self.canvas = prntxtctrl.canvas
  ==> self.log = prntxtctrl.log
         printout = PrintFramework.MyPrintout(self.canvas, self.log)
         if not printer.Print(self, printout):
             wxMessageBox("Printer Problem")
         else:
             self.printData =
printer.GetPrintDialogData().GetPrintData()
         printout.Destory()

____

Upon running this, I get the following error:

File: ... \PrintFramework.py, Line 42 in GePageInfo
self.log.WriteText
         ("wxPrintout.GetPageInfo\n")
Attribute Error: 'str' object has no attribute 'WriteText'

TypeError: GetPageInfo should return a tuple of 4 integers

Upon checking with "wxWindows Reference" in the "wxPython Notes" I
notice that GetPageInfo is not implemented in wxPython.

Can you tell me when GetPageInfo will be implemented?

Also, is there anything in my coding I should change after
GetPageInfo > is implemented?

Thanks again for your assistance.

From what little exposure I have had to wxPython, I beleive it is
great. I tried Java and Xbasic but so far wxPython is my choice.

Keep up the good work.

__________________________________________________
Do You Yahoo!?
Yahoo! Games - play chess, backgammon, pool and more
http://games.yahoo.com/

···

--- DJ Webre <d_webre@yahoo.com> wrote:

--- DJ Webre <d_webre@yahoo.com> wrote:

__________________________________________________
Do You Yahoo!?
Yahoo! Games - play chess, backgammon, pool and more
http://games.yahoo.com/

What is your final goal?

1. If your final goal is merely to print from a wxTextCtrl, then
you can probably do no better than to use Jeff's prntxtwx.py. If
multiple pages causes a problem (as you implied), maybe we could
figure out what that problem is and find a fix or workaround.

2. If your goal is to understand the wxPython/wxWindows Print
Framework, I would be glad to help out to the extent that I can,
but be warned that it is not simple. For my own study I started
working on a kind of tutorial, which I never completed, but FWIW I
will attach a copy of the preliminary draft to this posting.

3. If your goal is to print documents and reports from Python, the
conclusion that I have come to is that the easiest way is to
generate HTML and use wxHtmlEasyPrinting or wxHtmlPrintout. Someday
I would like to implement a cascading style sheet approach to
printing from wxPython, but priorities demand that work on a BUNCH
of other things first. Every day I print 25 nicely formatted
patient progress notes with HTML tables and lists using
wxHtmlPrintout.

print.html (16.5 KB)

···

--- DJ Webre <d_webre@yahoo.com> wrote:
I am trying to print from wxTextCtrl using PrintFramework ...

=====
Donnal Walter
Arkansas Children's Hospital

__________________________________________________
Do You Yahoo!?
Yahoo! Games - play chess, backgammon, pool and more
http://games.yahoo.com/

The attached figure may also be helpful.

···

--- Donnal Walter <donnalcwalter@yahoo.com> wrote:

For my own study I started working on a kind of tutorial,
which I never completed, but FWIW I will attach a copy of
the preliminary draft to this posting.

=====
Donnal Walter
Arkansas Children's Hospital

__________________________________________________
Do You Yahoo!?
Yahoo! Games - play chess, backgammon, pool and more
http://games.yahoo.com/

Donnal Walter wrote:

For my own study I started
working on a kind of tutorial, which I never completed, but FWIW I
will attach a copy of the preliminary draft to this posting.

Please consider putting this in the Wiki, we need all the docs we can
get!

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                        
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

2. If your goal is to understand the wxPython/wxWindows Print
Framework, I would be glad to help out to the extent that I can,
but be warned that it is not simple. For my own study I started
working on a kind of tutorial, which I never completed, but FWIW I
will attach a copy of the preliminary draft to this posting.

Can you please put a general version of this in the Wiki?

3. If your goal is to print documents and reports from Python, the
conclusion that I have come to is that the easiest way is to
generate HTML and use wxHtmlEasyPrinting or wxHtmlPrintout.

Yes, this meets most people's needs nicely.

···

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