您的位置:首页 > 编程语言 > Python开发

wxpython学习5

2015-11-21 01:15 656 查看
单行文本框与多行文本框
class TextCtrlFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, u'文本框', size=(300, 600))
panel = wx.Panel(self, -1)
label1 = wx.StaticText(panel, -1, u'姓名:', pos=(10, 10))
self.inputText = wx.TextCtrl(panel, -1, "", pos=(80, 10), size=(150, -1))
# 输入文本框
self.inputText.SetInsertionPoint(0)
label2 = wx.StaticText(panel, -1, u'密码:', pos=(10, 50))
# 密码输入框
self.pwdText = wx.TextCtrl(panel, -1, "", pos=(80, 50), size=(150, -1),
style=wx.TE_PASSWORD | wx.TE_PROCESS_ENTER)
self.Bind(wx.EVT_TEXT_ENTER, self.OnLostFocus, self.pwdText)

# 创建多行文本框
multText = wx.TextCtrl(panel, -1,
'Python is good language,'
'wxPython is a GUI API'
'good job!',
pos=(10, 100), size=(180, 80), style=wx.TE_MULTILINE | wx.TE_CENTER)
multText.SetBackgroundColour("red")
multText.SetFocus()

def OnLostFocus(self, evt):
wx.MessageBox('%s ,%s' % (self.inputText.GetValue(), self.pwdText.GetValue()), 'hint')

if __name__ == '__main__':
app = wx.PySimpleApp()
frame = TextCtrlFrame()
frame.Show()
app.MainLoop()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: