首页 > 试题广场 >

3 [问答]设计一个窗体,模拟QQ登录界面,当用户输入号码1

[问答题]
设计一个窗体,模拟QQ登录界面,当用户输入号码123456和密码654321时提示正确,否则提示错误。
import wx
class QQ(wx.Frame):
def __init__(self, superion):
wx.Frame.__init__(self, parent=superion, title='QQ', size=(300,200),pos=(350,350))
panel = wx.Panel(self)
panel.SetBackgroundColour('Red')
label1=wx.StaticText(panel,-1,'账号:',pos=(0,10),style=wx.ALIGN_CENTER)
label1=wx.StaticText(panel,-1,'密码:',pos=(0,30),style=wx.ALIGN_CENTER)
self.username=wx.TextCtrl(panel,-1,pos=(70,10),size=(160,20))
self.password=wx.TextCtrl(panel,pos=(70,30),size=(160,20),style=wx.TE_PASSWORD)
self.buttonOK = wx.Button(parent=panel, label='登录', pos=(70,60))
self.Bind(wx.EVT_BUTTON, self.OnButtonCheck, self.buttonOK)
self.buttonRes = wx.Button(parent=panel, label='注册', pos=(70,90))
self.Bind(wx.EVT_BUTTON, self.OnButtonRes, self.buttonRes)

def OnButtonCheck(self, event):
user=self.username.GetValue()
psw=self.password.GetValue()
if user == 'chuangshiyuanling' and psw == 'chuangshiyuanling07':
wx.MessageBox('成功!')
else:
wx.MessageBox('你输入的账号或密码有误!')
def OnButtonRes(self,event):
wx.MessageBox("账号:chuangshiyuanling密码:chuangshiyuanling07")

if __name__ == '__main__':
app = wx.App()
frame = QQ(None)
frame.Show()
app.MainLoop()

编辑于 2019-07-20 17:52:00 回复(0)
tkinter
发表于 2019-03-13 00:30:36 回复(0)