我正在尝试检索wxPython中面板的背景颜色
import wx
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, 'Panel colour')
panel = MainPanel(self)
main_sizer = wx.BoxSizer(wx.VERTICAL)
main_sizer.Add(panel)
self.SetSizerAndFit(main_sizer)
self.Centre()
self.Show()
print(self.GetBackgroundColour())
print(panel.GetBackgroundColour())
class MainPanel(wx.Panel):
def __init__(self, frame):
wx.Panel.__init__(self, frame)
lbl_description = wx.StaticText(self, label='Hello world')
main_sizer = wx.BoxSizer(wx.VERTICAL)
main_sizer.Add(lbl_description, flag=wx.ALL, border=10)
self.SetSizer(main_sizer)
if __name__ == "__main__":
screen_app = wx.App()
main_frame = MainFrame()
screen_app.MainLoop()
但我得到的输出是
(225, 225, 225, 255)
(225, 225, 225, 255)
显然,我做错了什么。我应该怎么做到?