码迷,mamicode.com
首页 > 其他好文 > 详细

生成聊天界面

时间:2018-06-17 15:10:15      阅读:384      评论:0      收藏:0      [点我收藏+]

标签:color   stat   exti   pre   append   %s   ctime   .text   time()   

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()

 

生成聊天界面

标签:color   stat   exti   pre   append   %s   ctime   .text   time()   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!