sys.exit()
def __init__(self, parent, id, title,user,un):
wx.Frame.__init__(self, parent, id, title,
- wx.DefaultPosition, wx.Size(200, 450))
+ wx.DefaultPosition, wx.Size(210, 450))
hbox = wx.BoxSizer(wx.HORIZONTAL)
vbox = wx.BoxSizer(wx.VERTICAL)
panel1 = wx.Panel(self, -1)
self.tree = wx.TreeCtrl(panel1, 1, wx.DefaultPosition, (-1, -1),
- wx.TR_HIDE_ROOT|wx.TR_HAS_BUTTONS)
+ wx.TR_HIDE_ROOT|wx.TR_DEFAULT_STYLE)
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, lambda evt,un=un : self.OnClickLeftKey(evt,un), self.tree)
root = self.tree.AddRoot('My friend')
for i in user['item']:
- ch=self.tree.AppendItem(root, i)
+ ch=self.tree.AppendItem(root, i)
for j in user[i]:
self.tree.AppendItem(ch, j)
vbox.Add(self.tree, 1, wx.EXPAND)
# encoding: utf-8
import os
import wx
-from wx.lib.pubsub import pub as Publisher
+from wx.lib.pubsub import setupkwargs
+from wx.lib.pubsub import pub
import sys
import ssl
import FriendList
self.passWord.Bind(wx.EVT_TEXT_ENTER,self.login_thread)
self.loginButton = wx.Button(self, label = _('Login'), pos = (80, 145), size = (130, 30))
self.loginButton.Bind(wx.EVT_BUTTON,self.login_thread)
- Publisher.subscribe(self.__Friend_list, 'list.show')
+ pub.subscribe(self.__Friend_list, 'list.show')
self.Show()
- def __Friend_list(self, info):
+ def __Friend_list(self, data):
#print 'Object', message.data, 'is added'
+ #print data
self.Hide()
- frame = FriendList.MyFrame(None, id=-1, title=_("Friend List"),user=info.data,un=self.userName.GetValue())
+ time.sleep(0.1)
+ frame = FriendList.MyFrame(None, id=-1, title=_("Friend List"),user=data,un=self.userName.GetValue())
frame.Show(True)
def login_thread(self,event):
thread.start_new_thread(self.login, ())
wx.CallAfter(self.loginButton.Enable)
passwd0 = pc.decrypt(passwd)
if self.passWord.GetValue()==passwd0:
- print 'OK'
#try:
#cursor.execute("SELECT uncompress(Data) FROM friendlist WHERE name = '%s' LIMIT 1"%(self.userName.GetValue()))
#data = json.loads(cursor.fetchone()[0])
#bubble_notify = Notify.Notification.new (_("Information"),_("Login Successful"),"file://" + os.path.abspath(os.path.curdir) + "/Chat-TYL.ico")
#wx.CallAfter(bubble_notify.show)
#wx.CallAfter(pub.sendMessage,'list.show', data)
+ try:
+ data = urllib2.urlopen("http://chat-tyl.coding.io/put_db.php?content=LIST&db=FRIEND&where=NAME&where_t=" + self.userName.GetValue()).read()
+ except urllib2.HTTPError,e:
+ wx.CallAfter(wx.MessageBox,_('Unable to fetch data'),_('Error'), wx.OK | wx.ICON_ERROR)
+ wx.CallAfter(self.loginButton.Enable)
+ time.sleep(0.1)
+ wx.CallAfter(pub.sendMessage,'list.show', data=json.loads(data))
else:
wx.CallAfter(wx.MessageBox,_('Your Password is wrong'), _('Try it again'),
wx.OK | wx.ICON_ERROR)
- #wx.CallAfter(self.loginButton.Enable)
+ wx.CallAfter(self.loginButton.Enable)
if __name__ == '__main__':
pc = prpcrypt('keyskeyskeyskeys')
app = wx.App()