-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindow.py
96 lines (66 loc) · 2.35 KB
/
window.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
import os
import sys
import socket
from threading import *
import PySimpleGUI as w
# from tools.tools import *
from server import *
from client.client import *
# run command if failure: >$: export PYTHONPATH=/path/to/parent:$PYTHONPATH
'''
todo:
- fix multiple enter button bindings
- register user uploads shared file description
- keyword search feature
- remote host/file name retrieves the file
'''
'''
COMMAND SYNTAX:
- CONNECT <ip:port>
- QUER <keyword>
- RETR <filename>
- QUIT
'''
def run_window():
log("running GUI...")
window = open_window("host")
tables_values = []
client_list = []
# todo: fix window bug, integrate Client and Server classes into the GUI
# todo: RETR command via GUI will retrieve all files in the shared directory space
while True:
event, values = window.read()
if event == CLOSED_WINDOW():
break
elif event == CONNECT_BUTTON_LABEL:
hostname = values["hostname"]
port = values["port"]
username = values["username"]
speed = values["speed"]
new_entry = [values["speed"], values["hostname"], values["port"]]
# table new connection information
if new_entry not in tables_values:
log(f'connecting to {hostname}:{port} set to {speed}...')
# create a new client object with our properties
# client_list.append(Client(host = new_entry[1], port = int(new_entry[2])))
tables_values.append(new_entry)
table = window.find_element("table")
table.update(values = tables_values, num_rows = len(tables_values))
elif event == SEARCH_BUTTON_LABEL:
keyword = values["keyword"]
log(f'searching for keyword \'{keyword}\'...')
elif event == COMMAND_BUTTON_LABEL:
command = values["command"]
log(f'command entered: {command}')
window.close()
def run_server():
log("running server...")
def main():
launch_window = Thread(target = run_window)
launch_window.start()
launch_server = Thread(target = run_server)
launch_server.start()
launch_window.join()
launch_server.join()
if __name__ == '__main__':
main()