import wx class MyApp(wx.App): def __init__(self): super(MyApp,self).__init__() class MyFrame(wx.Frame): def __init__(self,title='test',size=wx.DefaultSize): super(MyFrame,self).__init__(None,wx.ID_ANY,title=title,size=size,style=wx.DEFAULT_FRAME_STYLE^wx.MINIMIZE_BOX) self.Center() #self.SetSize(700,700) #self.SetTitle('aaa') if __name__ == '__main__': app = MyApp() frame = MyFrame(title='wx-test',size=(400,300)) frame.Show() app.MainLoop()
运行后:
Frame:
None:即parent=None,表示为顶层窗口
wx.ID_ANY:当id的值为-1或者wx.ID_ANY时,系统会随机分配一个id
style:样式,wx.DEFAULT_FRANME_STYLE的值为:wx.MINIMIZE_BOX|wx.MAXIMIZE_BOX|wx.RESIZE_BORDER|wx.SYSTEM_MENU|wx.CAPTION|wx.CLOSE_BOX,增加一个样式用‘|’,去除一个样式用‘^’,例如禁止调整窗口大小可以用wx.DEFAULT_FRANME_STYLE^wx.RESIZE_BORDER