From 175e6b55e9dedf575dab1c3ea2f2422b0725c128 Mon Sep 17 00:00:00 2001 From: flifloo Date: Fri, 19 Jul 2019 15:47:45 +0200 Subject: [PATCH] Lock text box, change some tkinter conf to remove useless import, change default command suffix --- gui.py | 12 +++++++----- server.py | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gui.py b/gui.py index 045c5b3..f9850b4 100644 --- a/gui.py +++ b/gui.py @@ -1,4 +1,4 @@ -from tkinter import Tk, Frame, Scrollbar, Label, Text, Button, Entry, StringVar, IntVar, LEFT, RIGHT, BOTH, Y, END +from tkinter import Tk, Frame, Scrollbar, Label, Text, Button, Entry, StringVar, IntVar from tkinter.messagebox import showerror from client import Client from threading import Thread @@ -29,7 +29,9 @@ def receive(): break if msg[-1:] != "\n": msg += "\n" - chat_message.insert(END, msg) + chat_message.configure(state="normal") + chat_message.insert("end", msg) + chat_message.configure(state="disable") def send(event=None): @@ -57,9 +59,9 @@ tchat.protocol("WM_DELETE_WINDOW", on_closing) chat = Frame(tchat) chat.pack() scrollbar = Scrollbar(chat) -scrollbar.pack(side=RIGHT, fill=Y) -chat_message = Text(chat, height=15, width=50, yscrollcommand=scrollbar.set) -chat_message.pack(side=LEFT, fill=BOTH) +scrollbar.pack(side="right", fill="y") +chat_message = Text(chat, height=15, width=50, yscrollcommand=scrollbar.set, state="disable") +chat_message.pack(side="left", fill="both") Thread(target=receive).start() entry = Frame(tchat) diff --git a/server.py b/server.py index 6941b33..74780bf 100644 --- a/server.py +++ b/server.py @@ -10,8 +10,8 @@ class Server(Socket): self.socket.bind((host, port)) self.socket.listen(5) self.service_id = service_id - self.command_suffix = "!" - self.welcom_msg = "Welcom ! Type \"!help\" to see commands and \"quit\" to exit" + self.command_suffix = "/" + self.welcom_msg = "Welcom ! Type \"/help\" to see commands and \"quit\" to exit" self.commands = {"help": self.command_help, "players list": self.command_players_list} self.clients = dict() print("Wait for connexion...")