Hi Ray, Che and Raoul,
On Fri, Jul 16, 2010 at 12:14 PM, WinCrazy <pas...@verizon.net> wrote:
> Mike - I am actually trying to modify your own example showing how to
> redirect sys.stdout to a textCtrl. Adding "wx.TE_RICH" or
> "wx.TE_RICH2" to the style has no effect.
> C M - I made a transcription error. Here's the actual code.:
> wx.Frame.__init__( self, None, wx.ID_ANY, 'wxPython Redirect
> Tutorial' )
> # Add a panel so it looks the same on all platforms
> panel = wx.Panel( self, wx.NewId() )
> #tcStyle = wx.TE_MULTILINE|wx.TE_READONLY|wx.VSCROLL|
> wx.HSCROLL| wx.TE_RICH
> tcStyle = wx.TE_MULTILINE|wx.TE_READONLY|wx.VSCROLL|
> wx.HSCROLL| wx.TE_RICH2
> logTC = wx.TextCtrl( panel, wx.NewId(), size=(300, 100),
> style=tcStyle )
> # Set a monospace font
> tcFont = logTC.GetFont()
> tcFont.SetFamily( wx.FONTFAMILY_TELETYPE )
> logTC.SetFont( tcFont )
> ## This works, but it is not acceptable because
> ## I must know what are the last 2 arg values before the call.
> ##
> ##tcFontSize = tcFont.GetPointSize()
> ##logTC.SetFont( wx.Font( tcFontSize, wx.FONTFAMILY_TELETYPE,
> wx.NORMAL, wx.NORMAL ) )
> On Jul 15, 1:46 pm, C M <cmpyt...@gmail.com> wrote:
> > On Thu, Jul 15, 2010 at 9:45 AM, Mike Driscoll <kyoso...@gmail.com> > > wrote:
> > > On Jul 14, 3:41 pm, Raoul <raoulpa...@yahoo.com> wrote:
> > > > Hi. I want to change just the font in a TextCtrl. Why does this have
> > > > no effect in MS Windows ? No errors are reported.
> > > > myTC = wx.TextCtrl( ... )
> > > > tcFont = myTc.GetFont() # OK
> > > > tc.Font.SetFamily( wx.FONTFAMILY_TELETYPE ) # ? works ?
> > > > myTC.SetFont( tcFont ) # ? works ?
> > > > { write text to myTC ... } # text appears but in the original font
> > > > face
> > Above, you get the current font and call it tcFont. Later you SetFont()
> on
> > the textCtrl using tcFont. So it will be the same font. In your middle
> > step, you haven't written tcFont, but tc.Font. You have 'stored' the
> > original font in the name tcFont. I think that's the problem.
> > Che
I just tried creating my own fun example. It works for me on Windows XP Pro,
wxPython 2.8.10.1, Python 2.5. Let me know if it works for you guys!
--
-----------------
Mike Driscoll
Blog: http://blog.pythonlibrary.org
redirect.py
2KViewDownload