Josh, I'm not sure... but the code below emulates my result. I'm pretty
sure the code is "wrong" to do what I'm trying to do. I'm trying to set
colors in real time, so "show" the user what his color choices / font would
look like.
Robin, I'm going to try real hard to sound like I know what I'm doing.
But I don't actually set any colors initially. The standard black text
on white background, with the system font is what I use as the "generic"
settings.
<CODE>
import wx
class TCFrame(wx.Frame):
def __init__(self, parent, id, title):
Frame = wx.Frame.__init__(self, parent, id, title)
TCPanel = wx.Panel(self, wx.ID_ANY)
self.TC = wx.TextCtrl(TCPanel, style=wx.TE_MULTILINE)
BGTC = wx.Button(TCPanel, wx.ID_ANY, 'Background Color')
Box = wx.BoxSizer(wx.VERTICAL)
Box.Add(self.TC, 4, wx.EXPAND)
Box.Add(BGTC, 1, wx.EXPAND)
TCPanel.SetSizer(Box)
self.Bind(wx.EVT_BUTTON, self.BGEvent, BGTC)
def BGEvent(self, event):
dlg = wx.ColourDialog(self)
if dlg.ShowModal() == wx.ID_OK:
BGColorData = dlg.GetColourData()
BGColor = str(BGColorData.GetColour().Get())
self.TC.SetBackgroundColour(BGColor)
self.TC.WriteText('Sample Text')
dlg.Destroy()
event.Skip()
class TCApp(wx.App):
def OnInit(self):
Frame = TCFrame(None, -1, 'TC Example')
Frame.Show(True)
return True
App = TCApp()
App.MainLoop()
</CODE>
···
----- Original Message ----- From: "Robin Dunn" <robin@alldunn.com>
To: <wxpython-users@lists.wxwidgets.org>
Sent: Monday, 04 August, 2008 14:35
Subject: Re: [wxpython-users] wx.TextCtrl goes ape.
Steve Freedenburg wrote:
Ok, so I've been experimenting alot, and playing with code.
I thought it would be a good idea to have a "sample" TextCtrl
that would have some "Sample Text" in it, and the user
could pick the bg color, fg color, and font and the
TextCtrl would update.
If I set the color before the TextCtrl is created everything is
peachy.
How do you set the colors if the TextCtrl hasn't been created yet? Or do you set it on the parent?
But it I try and SetBackgroundColor, the TextCtrl line
with text changes, the background turns purple, the text
turns black, and the read of the lines in TextCtrl turn black
no matter what color I choose.
The foreground color doesn't seem to change at all.
Show(False) / setcolor / Show(True) doesn't work.
Refresh() doesn't work either. Update()
Please make a small runnable sample that shows what you are trying to do.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users