首页 > 其他 > 详细

生成聊天界面

时间:2018-06-17 14:38:40      阅读:235      评论:0      收藏:0      [点我收藏+]
import wx
import time
class MyFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self,None,-1,"Milo‘s Chat",size=(520,450))
        panel=wx.Panel(self)
        labelAll=wx.StaticText(panel,-1,"All Contents",pos=(210,5))
        self.textAll=wx.TextCtrl(panel,-1,
                                 size=(480,195),
                                 pos=(10,25),
                                 style=wx.TE_MULTILINE|wx.TE_READONLY)
        labelIn=wx.StaticText(panel,-1,"I Say",pos=(210,225))
        self.textIn=wx.TextCtrl(panel,-1,
                                 size=(480,100),
                                 pos=(10,245),
                                 style=wx.TE_MULTILINE)
        self.bunSent=wx.Button(panel,-1,"Sent",size=(75,25),pos=(130,365))
        self.bunClear=wx.Button(panel,-1,"Clear",size=(75,25),pos=(260,365))
        self.Bind(wx.EVT_BUTTON,self.OnButtonSent,self.bunSent)
        self.Bind(wx.EVT_BUTTON,self.OnButtonClear,self.bunClear)
    def OnButtonSent(self,event):
        userinput=self.textIn.GetValue()
        self.textIn.Clear()
        now=time.ctime()
        inmsg="you(%s):\n%s\n\n " %(now,userinput)
        #self.textAll.SetValue(userinput)
        self.textAll.AppendText(inmsg)
    def OnButtonClear(self,event):
        pass

app=wx.App()
frame=MyFrame()
frame.Show()
app.MainLoop()

 

生成聊天界面

原文:https://www.cnblogs.com/1304379017dwh/p/9192768.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!