我正在编写一个 Python 应用程序,我想获取包含 gui 的面板(窗口)的颜色。这取决于主题。是否可以通过编程方式检索主题颜色?我试过:
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()