From: Malte Bublitz Date: Tue, 12 Feb 2013 21:40:53 +0000 (+0100) Subject: Added pm function, improved GUI. X-Git-Url: https://git.rt3x.de/?a=commitdiff_plain;h=cb5dd494e9320b9518977880b3d1dac169151750;p=simple-chat.git Added pm function, improved GUI. --- diff --git a/client.py b/client.py index a0bb6c7..72a96c2 100644 --- a/client.py +++ b/client.py @@ -5,6 +5,10 @@ # import socket +import threading +import time +import select, sys +import wx class ChatClient(object): queue = [] @@ -41,23 +45,24 @@ class ChatClient(object): return command else: return False - -import threading -import time -import select, sys -import wx - class SimpleChatFrame(wx.Frame): def __init__(self, *args, **kwds): wx.Frame.__init__(self, *args, **kwds) - # Menu Bar - self.frame_1_menubar = wx.MenuBar() - wxglade_tmp_menu = wx.Menu() - menu_quit = wxglade_tmp_menu.Append(wx.NewId(), "Quit", "", wx.ITEM_NORMAL) - self.Bind(wx.EVT_MENU, self.OnQuit, menu_quit) - self.frame_1_menubar.Append(wxglade_tmp_menu, "SimpleChat") - self.SetMenuBar(self.frame_1_menubar) + + # Menu bar + self.menubar = wx.MenuBar() + mainmenu = wx.Menu() + menu_about = mainmenu.Append(wx.ID_ABOUT, "Über...\tF1") + menu_quit = mainmenu.Append(wx.ID_EXIT, "Beenden\tCtrl+Q") + chatmenu = wx.Menu() + menu_pm = chatmenu.Append(wx.ID_NEW, "Neue private Nachricht\tCtrl+P") + self.menubar.Append(mainmenu, "SimpleChat") + self.menubar.Append(chatmenu, "Chat") + self.SetMenuBar(self.menubar) + self.Bind(wx.EVT_MENU, self.OnAbout, menu_about) + self.Bind(wx.EVT_MENU, self.OnQuit, menu_quit) + self.Bind(wx.EVT_MENU, self.OnPrivMsg, menu_pm) # Menu Bar end self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE) self.text_ctrl_2 = wx.TextCtrl(self, -1, "") @@ -92,6 +97,25 @@ class SimpleChatFrame(wx.Frame): self.chat.exit() self.Close() + def OnAbout(self, ev): + DEV_MALTE_BUBLITZ = "Malte Bublitz " + aboutInfo = wx.AboutDialogInfo() + aboutInfo.AddDeveloper(DEV_MALTE_BUBLITZ) + aboutInfo.SetCopyright("Copyright © 2013, Malte Bublitz (https://malte-bublitz.de)") + aboutInfo.SetName("SimpleChat") + aboutInfo.SetVersion("0.20130212") + aboutInfo.SetWebSite("https://github.com/malte70/simple-chat") + wx.AboutBox(aboutInfo) + + def OnPrivMsg(self, ev): + dlg = wx.TextEntryDialog(None, "An wen?", "Empfänger?") + if dlg.ShowModal() == wx.ID_OK: + to = dlg.GetValue() + dlg2 = wx.TextEntryDialog(None, "Die Nachricht?", "Nachricht") + if dlg2.ShowModal() == wx.ID_OK: + msg = dlg2.GetValue() + self.chat.one(to, msg) + class RecvThread(threading.Thread): def __init__(self, parent): threading.Thread.__init__(self) @@ -115,13 +139,8 @@ class RetrieveThread(threading.Thread): #chat.exit() if __name__ == "__main__": app = wx.PySimpleApp(0) - wx.InitAllImageHandlers() - frame_1 = SimpleChatFrame(None, -1, "") - app.SetTopWindow(frame_1) - frame_1.Show() - #while True: - # x = frame_1.chat.retrieve() - # if x != False: - # #self.parent.text_ctrl_1.AppendText(x+"\n") - # print x + #wx.MessageBox('This software might crash...', 'Attention', wx.OK | wx.ICON_WARNING) + frame = SimpleChatFrame(None, -1, "") + app.SetTopWindow(frame) + frame.Show() app.MainLoop()