from tkinter import scrolledtext
tk.Label(mainWindow, text='Введите логин: ').grid(row=0, column=0)
user_name_input = tk.Entry(mainWindow)
user_name_input.grid(row=0, column=1)
tk.Button(mainWindow, text='Подключиться', command=lambda: login(user_name_input.get())).grid(row=0, column=2)
for widget in mainWindow.winfo_children():
nickname = mes_code(nickname)
sock.sendto(nickname.encode(), server)
chat_area = scrolledtext.ScrolledText(mainWindow, height=15)
chat_area.configure(state=tk.DISABLED)
input_frame = tk.Frame(mainWindow)
input_area = tk.Entry(input_frame)
input_area.pack(side=tk.LEFT, fill=tk.X, expand=True, padx=(0, 5))
send_button = tk.Button(input_frame, text='Отправить', command=lambda: send_message(input_area))
send_button.pack(side=tk.LEFT)
input_frame.pack(fill=tk.BOTH, expand=True, padx=5)
get_mes = threading.Thread(target=get_message, args=(chat_area,))
def send_message(input_field):
input_field.delete(0, tk.END)
mes = mes_code(': ' + mes)
sock.sendto(data.encode(), server)
def get_message(chat_area):
new_mes = sock.recv(1024)
chat_area.configure(state=tk.NORMAL)
new_mes = mes_decode(new_mes.decode())
chat_area.insert(tk.END, new_mes + '\n')
chat_area.configure(state=tk.DISABLED)
code_mes += sym[(sym.index(s) + 7) % len(sym)]
decode_mes += sym[(sym.index(s) - 7) % len(sym)]
sym = 'ецDСonн0щйg-=KЬ+Уk3ч!ХЩдWкTФSъCЭMьТt_ЪБП8^@bVxcqiтэ$ЗЖ2юuхаШуjeI#и(РHовE56шлЧКUQзО*ИЁmhw17NY4rJпXЕ:АЫЯ;zДяМp,' \
'ЮмсOВyB№ЦЛFГ)P/фdfбsрZAvёыRL?G&9Й.Нlж%aг '
server = '176.121.241.20', 9090
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
mainWindow.title("Супер чат")
mainWindow.geometry('400x300')
sock.sendto('0'.encode(), server)