from Tkinter
import *
import tkMessageBox
from PIL
import Image, ImageTk
from ftplib
import *
from wxpy
import *
import os
from collections
import OrderedDict
import datetime
import time
class Aplication(Tk):
def __init__(self):
Tk.__init__(self)
def login(self):
print self.Test
self.Test+=
1
self.destroy()
self.quit()
print self.Test
def sendmsg(self):
msgcontent = unicode(
'me:',
'eucgb2312_cn') + time.strftime(
"%Y-%m-%d %H:%M:%S",time.localtime()) +
'\n '
self.text_msglist.insert(END, msgcontent,
'green')
self.text_msglist.insert(END, self.text_msg.get(
'0.0', END))
self.text_msg.delete(
'0.0', END)
def startChat(self,event):
print 'start to chat'
def updateFriendList(self):
print 'Update friend List'
if self.box_friendlist.size()>
0:
self.box_friendlist.delete(
0,END)
for i
in range(len(self.friendList)):
self.box_friendlist.insert(END, self.friendList[i].decode(
'gbk').encode(
'utf8'))
def setupChatUI(self):
self.title(
'WeChat'.decode(
'gbk'))
self.resizable(
False,
False)
self.iconbitmap(
'logo.ico')
self.attrFrame = Frame(width=
420, height=
100, bg=
'gray')
self.friendFrame = Frame(width=
200, height=
530, bg=
'Blue')
self.msgFrame = Frame(width=
420, height=
300, bg=
'gray')
self.sendMsgFrame = Frame(width=
420, height=
100, bg=
'gray')
self.buttomFrame = Frame(width=
420, height=
50,bg=
'gray')
self.buttonFrame = Frame(width=
50, height=
41)
self.text_msglist = Text(self.msgFrame)
self.text_msg = Text(self.sendMsgFrame)
self.text_attri = Text(self.attrFrame)
self.box_friendlist = Listbox(self.friendFrame,width=
10,height=
28)
self.button_sendmsg = Button(self.buttonFrame,text=
'发送'.decode(
'gbk'),font=(
'Arial',
15),command=self.sendmsg)
self.button_updateFriendList = Button(self.friendFrame,text=
'更新好友列表'.decode(
'gbk'),width=
28,command=self.updateFriendList,bg=
'RED')
self.text_msglist.tag_config(
'green',foreground=
'#008B00')
self.attrFrame.grid(row=
0,column=
0,padx=
2,pady=
5,sticky=W+E+N+S)
self.msgFrame.grid(row=
1,column=
0,padx=
2,pady=
5,sticky=W+E+N+S)
self.sendMsgFrame.grid(row=
2,column=
0,padx=
2,pady=
5,sticky=W+E+N+S)
self.friendFrame.grid(row=
0,column=
1,rowspan=
3,padx=
4,pady=
5,sticky=W+E+N+S)
self.buttomFrame.grid(row=
3,column=
0,padx=
2,pady=
5,sticky=W+E+N+S)
self.buttonFrame.grid(row=
3,column=
0,sticky=W+E+N+S)
self.attrFrame.grid_propagate(
0)
self.msgFrame.grid_propagate(
0)
self.sendMsgFrame.grid_propagate(
0)
self.friendFrame.grid_propagate(
0)
self.buttonFrame.grid_propagate(
0)
self.buttonFrame.grid_propagate(
0)
Label(self.attrFrame,width=
380,height=
1,bg=
'Blue').grid(sticky=E+W+N+S)
self.button_updateFriendList.grid(sticky=E+W+N+S)
Label(self.friendFrame,text=
'我的好友'.decode(
'gbk') ,bg=
'Green').grid(padx=
4,pady=
5,sticky=E+W+N+S)
self.text_msglist.grid(sticky=E+W+N+S)
self.text_msglist.grid_propagate(
0)
self.text_msg.grid(sticky=E+W+N+S)
self.box_friendlist.bind(
'<Double-Button-1>',self.startChat)
self.box_friendlist.grid(sticky=E+W+N+S)
self.button_sendmsg.grid(sticky=E+W+N+S)
def setupLoginUI(self):
print 'Login'
self.title(
'WeChat'.decode(
'gbk'))
self.resizable(
False,
False)
self.geometry(
'350x300+500+100')
self.iconbitmap(
'logo.ico')
self.canvas=Canvas(self,width=
350,height=
190)
self.canvas.grid(row=
0,column=
0)
self.im=Image.open(
'timg.jpg')
self.tkim=ImageTk.PhotoImage(self.im)
self.canvas.create_image(
0,
0,anchor=NW,image=self.tkim)
Button(self,text=
'登录'.decode(
'gbk'),bg=
'GREEN',width=
30,height=
2,command=self.login).grid(row=
1,column=
0,sticky=N)
bot=
None
Test=
1
friendAttribute = ([
'姓名',
'穆'],[
'性别',
'男'],[
'年龄',
'25'],[
'城市',
'深圳'])
friendList = [
'穆',
'吴',
'樊',
'高']
if __name__==
'__main__':
login = Aplication()
login.setupLoginUI()
login.mainloop()
chat = Aplication()
chat.setupChatUI()
chat.mainloop()