-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtkinter_app.py
97 lines (73 loc) · 1.94 KB
/
tkinter_app.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import tkinter as tk
import asyncio
FPS = 20
"""
Legende :
<entry>
[button]
'text'
|---------------|
| host: <...> |
| port: <...> |
| nick: <...> |
| |
| [connect] |
|---------------|
=>
|--------------------------------|
|[server] [#home] [#python] |
|--------------------------------|
| 'Chat content' | 'User' |
| 'Chat content' | 'User' |
| Message : <...> | |
|--------------------------------|
"""
async def mainloop(root):
while True:
root.update()
await asyncio.sleep(1 / FPS)
class Vue(tk.Frame):
def __init__(self, master, inputs):
super().__init__(master)
self.inputs_function = inputs
self.widgets = []
self.load()
def output(self, kwargs):
...
def load(self):
...
class ConnectVue(Vue):
def load(self):
self.choose_host = tk.StringVar()
host_text = tk.Label(self, text="Host :")
host_text.pack()
host_entry = tk.Entry(self, textvariable=self.choose_host)
host_entry.pack()
self.choose_port = tk.StringVar()
port_text = tk.Label(self, text="Port :")
port_text.pack()
port_entry = tk.Entry(self, textvariable=self.choose_port)
port_entry.pack()
self.choose_nick = tk.StringVar()
nick_text = tk.Label(self, text="Nick :")
nick_text.pack()
nick_entry = tk.Entry(self, textvariable=self.choose_nick)
nick_entry.pack()
connect_button = tk.Button(self, text="Connect")
connect_button.pack()
async def switch(app):
while True:
await asyncio.sleep(1)
app.pack_forget()
await asyncio.sleep(1)
app.pack()
def main():
root = tk.Tk()
app = ConnectVue(root, "")
app.pack()
loop = asyncio.new_event_loop()
loop.create_task(mainloop(root))
loop.create_task(switch(app))
loop.run_forever()
if __name__ == "__main__":
main()