python设计一个窗体、模拟登录页面_设计一个窗体,模拟QQ登录界面,当用户输入号码123456和...

Python 2.7.8代码如下,

import wx

class wxGUI(wx.App):

def OnInit(self):

frame = wx.Frame(parent=None, title='Login', size=(250,150), pos=(350,350))

panel = wx.Panel(frame, -1)

label1 = wx.StaticText(panel, -1, 'UserName:', pos=(0,10), style=wx.ALIGN_RIGHT)

label2 = wx.StaticText(panel, -1, 'Password:', pos=(0,30), style=wx.ALIGN_RIGHT)

self.textName = wx.TextCtrl(panel, -1, pos=(70,10), size=(160,20))

self.textPwd = wx.TextCtrl(panel, -1, pos=(70,30), size=(160,20),style=wx.TE_PASSWORD)

buttonOK = wx.Button(panel, -1, 'OK', pos=(30,60))

self.Bind(wx.EVT_BUTTON, self.OnButtonOK, buttonOK)

buttonCancel = wx.Button(panel, -1, 'Cancel', pos=(120,60))

self.Bind(wx.EVT_BUTTON, self.OnButtonCancel, buttonCancel)

buttonOK.SetDefault()

frame.Show()

return True

def OnButtonOK(self, event):

usrName = self.textName.GetValue()

usrPwd = self.textPwd.GetValue()

if usrName=='123456' and usrPwd=='654321':

wx.MessageBox('Right')

else:

wx.MessageBox('Wrong')

def OnButtonCancel(self, event):

pass

app = wxGUI()

app.MainLoop()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值