This repository has been archived by the owner on Oct 21, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
weschat.py
68 lines (50 loc) · 1.87 KB
/
weschat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from weschat_api import WesChat
import tkinter
import json
import os
window = tkinter.Tk()
window.title("WesChat")
files = os.listdir("themes")
print("Choose a theme")
for i, file in enumerate(files):
print(i, file)
num = int(input("Enter the theme number: "))
with open("themes/"+files[num]) as file:
theme = json.loads(file.read())
font = tuple(theme["font"])
wc = None
def connect():
global wc, hostEntry, passEntry
wc = WesChat(hostEntry.get(), passEntry.get())
def post(blah=None):
global wc, postEntry
wc.post(postEntry.get())
postEntry.delete(0, tkinter.END)
connectBtn = tkinter.Button(window, text="Connect", command=connect,
font=font)
postBtn = tkinter.Button(window, text="Post", command=post,
font=font)
hostLabel = tkinter.Label(window, text="Server IP:", font=font)
passLabel = tkinter.Label(window, text="Password:", font=font)
hostEntry = tkinter.Entry(window, font=font)
passEntry = tkinter.Entry(window, font=font, show="*")
postEntry = tkinter.Entry(window, font=font)
msgLabel = tkinter.Text(window, font=font, wrap=tkinter.WORD)
connectBtn.grid(row=0, column=2, sticky=tkinter.E+tkinter.N)
postBtn.grid(row=3, column=2, sticky=tkinter.E, rowspan=2)
hostLabel.grid(row=0, column=0, sticky=tkinter.W+tkinter.N)
passLabel.grid(row=1, column=0, sticky=tkinter.W)
hostEntry.grid(row=0, column=1, sticky=tkinter.W+tkinter.E+tkinter.N)
passEntry.grid(row=1, column=1, sticky=tkinter.W+tkinter.E+tkinter.N)
postEntry.bind("<Return>", post)
postEntry.grid(row=3, column=0, columnspan=2, sticky=tkinter.W+tkinter.E)
msgLabel.grid(row=2, column=0, columnspan=3, sticky=tkinter.W)
window.rowconfigure(0, weight=1)
window.columnconfigure(1, weight=1)
while True:
window.update()
try:
msgLabel.insert(tkinter.END, wc.get_messages())
except:
pass
msgLabel.see(tkinter.END)