connect events to responses

This commit is contained in:
Manuel Cortez 2020-05-18 04:59:50 -05:00
parent 8e628e5b38
commit d73d58a4ce

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" Dfinition of all GUI components. """ """ Definition of all GUI components. """
import wx import wx
class loginDialog(wx.Dialog): class loginDialog(wx.Dialog):
@ -48,6 +48,12 @@ class loginDialog(wx.Dialog):
self.SetClientSize(sizer.CalcMin()) self.SetClientSize(sizer.CalcMin())
class appFrame(wx.Frame): class appFrame(wx.Frame):
menu_items = [
("create_room", "Create new room"),
("join_room", "Join a room")
]
secondary_menu_items = list()
def __init__(self): def __init__(self):
super(appFrame, self).__init__(parent=None, title="Chat Window") super(appFrame, self).__init__(parent=None, title="Chat Window")
self.Maximize(True) self.Maximize(True)
@ -60,12 +66,14 @@ class appFrame(wx.Frame):
self.sizer.Add(self.list, 1, wx.GROW) self.sizer.Add(self.list, 1, wx.GROW)
lbl = wx.StaticText(self.panel, -1, "Chat") lbl = wx.StaticText(self.panel, -1, "Chat")
self.chat = wx.TextCtrl(self.panel, -1) self.chat = wx.TextCtrl(self.panel, -1)
self.chat.Enable(False)
sizerchat = wx.BoxSizer(wx.HORIZONTAL) sizerchat = wx.BoxSizer(wx.HORIZONTAL)
sizerchat.Add(lbl, 0, wx.ALL, 5) sizerchat.Add(lbl, 0, wx.ALL, 5)
sizerchat.Add(self.chat, 0, wx.ALL, 5) sizerchat.Add(self.chat, 0, wx.ALL, 5)
self.sizer.Add(sizerchat, 0, wx.ALL, 5) self.sizer.Add(sizerchat, 0, wx.ALL, 5)
lbl1 = wx.StaticText(self.panel, wx.ID_ANY, "History") lbl1 = wx.StaticText(self.panel, wx.ID_ANY, "History")
self.history = wx.TextCtrl(self.panel, wx.ID_ANY, style=wx.TE_READONLY|wx.TE_MULTILINE, size=(500, 300)) self.history = wx.TextCtrl(self.panel, wx.ID_ANY, style=wx.TE_READONLY|wx.TE_MULTILINE, size=(500, 300))
self.history.Enable(False)
box = wx.BoxSizer(wx.HORIZONTAL) box = wx.BoxSizer(wx.HORIZONTAL)
box.Add(lbl1, 0, wx.ALL, 5) box.Add(lbl1, 0, wx.ALL, 5)
box.Add(self.history, 0, wx.ALL, 5) box.Add(self.history, 0, wx.ALL, 5)
@ -86,5 +94,11 @@ class appFrame(wx.Frame):
new_line = self.history.GetNumberOfLines()#.count("\n") new_line = self.history.GetNumberOfLines()#.count("\n")
return (old_line, new_line) return (old_line, new_line)
def enable_app(self):
for i in self.menu_items:
self.list.Append(i[1])
self.chat.Enable(True)
self.history.Enable(True)
def show_connection_error(self): def show_connection_error(self):
msg = wx.MessageDialog(None, "Connection error. Try again", "error", style=wx.ICON_ERROR).ShowModal() msg = wx.MessageDialog(None, "Connection error. Try again", "error", style=wx.ICON_ERROR).ShowModal()