We've just discovered that changing the pen and drawing text, e.g.
dc.SetPen(wx.Pen((255,0,0)))
dc.DrawText(10,10, "Hello, world!")
doesn't actually result in text in the desired color - instead it uses
whatever the foreground color of the underlying widget is set to. So
I can't draw text in multiple colors on a wx.DC right now. Is there
something I'm missing? (wxPython 2.9.4, wxOSX-Cocoa, OS 10.6, if it
matters.)
thanks,
Nat
Nat Echols wrote:
We've just discovered that changing the pen and drawing text, e.g.
dc.SetPen(wx.Pen((255,0,0)))
dc.DrawText(10,10, "Hello, world!")
doesn't actually result in text in the desired color - instead it uses
whatever the foreground color of the underlying widget is set to.
Text is never drawn with the current pen. It's drawn with the current
text color. Try
dc.SetTextForeground((255,255,0))
This is a historical implementation detail in Windows GDI. The pen is
used for lines, the brush is used for fills, and text had its own
attributes.
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
Thanks, that appears to do what I wanted, at least on Mac.
-Nat
···
On Tue, Dec 20, 2011 at 6:07 PM, Tim Roberts <timr@probo.com> wrote:
Text is never drawn with the current pen. It's drawn with the current
text color. Try
dc.SetTextForeground((255,255,0))