import wx
class Myframe(wx.frame):
def __init__(self,parent,id):
wx.frame.__init__(self,parent,id,title='hello baby',size=(500,300))
pane1=wx.Panel(self)
title=wx.StaticText(pane1,label='登录界面',pos=(100,20))
self.lable_user=wx.StaticText(pane1,label="请输入用户名",pos=(100,80))
self.text_user=wx.TextCtrl(pane1,pos=(200,80),size=(200,30),style=wx.TE_LEFT)
self.lable_psd = wx.StaticText(pane1, label="请输入密码",pos=(100,120))
self.text_psd = wx.TextCtrl(pane1, pos=(200, 120), size=(200, 30), style=wx.TE_PASSWORD)
self.bt_confirm=wx.Button(pane1,label='登录',pos=(210,170))
self.bt_cancel = wx.Button(pane1, label='退出',pos =(290, 170))
self.bt_/confirm/i.Bind(wx.EVT_BUTTON, self.Onclicksubmit)
self.bt_cancel.Bind(wx.EVT_BUTTON,self.Onclickcancel)
def onclicksubmit(self, Event):
# message=''
username = self.text_user.GetValue()
password = self.text_psd.GetValue()
if username =='' or password=='':
message = '用户名或密码不能为空'
elif username == 'mr' and password == '123':
message = '登录成功'
else:
message = '用户名或密码不正确'
wx.MessageBox(message)
def onclickcancel(self, event):
self.text_user.SetValue('')
self.text_psd.SetValue('')
if __name__=='__main__':
app =wx.App()
frame=Myframe(parent=None,id=-1)
frame.Show()
app.MainLoop()
复制粘贴格式有点问题需要微调



