Hi, everyone,
On Windows XP, wxPython 2.8.3.0, I set the background of a wxTextCtrl
to that of a wxStaticText on the same nootbook panel. Still, they show
different background colors.
In the test code below, the 'label' and 'text' objects both are set to
the same background color, but they are different to the eye. What's
happening here?
When I put the same two objects onto a panel as a direct child of the
frame, they have the same background color. So it seems that the
notebook widget is playing some strange game here. Can anyone give me
an hint and tell me how to set the background color of the TextCtrl to
that of the notebook panel, so that the TextCtrl will appear like a
StaticText?
Best Regards,
···
--
Hong Yuan
大管家网上建材超市
装修装潢建材一站式购物
http://www.homemaster.cn
import wx
class MyFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title,
pos=(150, 150), size=(350, 300))
notebook = wx.Notebook(self)
panel = wx.Panel(notebook)
label = wx.StaticText(panel, -1, "Hello World!")
text = wx.TextCtrl(panel, -1, "Hello World!",
style=wx.TE_READONLY|wx.NO_BORDER|wx.TRANSPARENT_WINDOW)
text.SetBackgroundColour(label.GetBackgroundColour())
assert text.GetBackgroundColour() == label.GetBackgroundColour()
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(label, 0, wx.ALL, 10)
sizer.Add(text, 0, wx.ALL, 10)
panel.SetSizer(sizer)
panel.Layout()
notebook.AddPage(panel, "Page1")
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, "Test")
self.SetTopWindow(frame)
frame.Show(True)
return True
app = MyApp(redirect=False)
app.MainLoop()