def on_closing(): """This function is to be called when the window is closed.""" # ask to close the application. if tkinter.messagebox.askokcancel("Quit", "Do you really wish to quit?"): top.destroy() encoded_message = ClientHelper().encodemessage('has left the chat.') client_socket.send(encoded_message.encode()) client_socket.close() else: pass
def send(event=None): # event is passed by binders. """Handles sending of messages.""" msg = my_msg.get() my_msg.set("") # Clears input field encoded_message = ClientHelper().encodemessage(msg) client_socket.send(encoded_message.encode()) if msg == "quit": client_socket.close() top.destroy() top.quit()