面板的背景颜色应用于整个框架!为什么会这样,我想知道。在这里,frame 是 (300,400),而 panel 应该是 (300,180)。我可能做错了什么。
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import wx
class Panel(wx.Panel):
def __init__(self, parent, id, pos, size):
wx.Panel.__init__(self, parent, id, pos, size)
class Frame(wx.Frame):
def __init__(self, parent, id, title, pos, size, style):
wx.Frame.__init__(self, parent, id, title, pos, size, style)
self.userpanel = Panel(self, -1, (0,0), (300,180))
self.userpanel.SetBackgroundColour('Gold')
class Application(wx.App):
def __init__(self):
wx.App.__init__(self)
frame = Frame(None, -1, "Internet Login Tool", (-1,-1), (300,400),\
wx.DEFAULT_FRAME_STYLE ^ (wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))
frame.Show()
self.SetTopWindow(frame)
if __name__ == '__main__':
app = Application()
app.MainLoop()