#
import socket
+import threading
+import time
+import select, sys
+import wx
class ChatClient(object):
queue = []
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, "")
self.chat.exit()
self.Close()
+ def OnAbout(self, ev):
+ DEV_MALTE_BUBLITZ = "Malte Bublitz <kontakt@malte-bublitz.de>"
+ 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)
#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()