forked from NelsonIg/Basic_Networking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filereception.py
59 lines (43 loc) · 1.67 KB
/
filereception.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
import tkinter as tk
from tkinter import*
import networking
import pdb
m = tk.Tk() #where m is the name of the main window object
m.title('Client')
def file_request():
#pdb.set_trace()
textConsole.delete('1.0',END)
c = networking.Client(entryAdrss.get(),int(entryPort.get()))
try:
file = c.get_file()
textConsole.insert(INSERT, file['content'])
except Exception as err:
print(err)
return
def close_server():
textConsole.delete('1.0',END)
c = networking.Client(entryAdrss.get(),int(entryPort.get()))
try:
c.close_server()
textConsole.insert(INSERT, 'server closed')
except Exception as err:
print(err)
return
var = tk.StringVar()
entryAdrss = tk.Entry(m)
entryAdrss.grid(row = 0, column = 1,padx = 4, pady = 4)
entryPort = tk.Entry(m)
entryPort.grid(row = 1, column = 1,padx = 4, pady = 4)
labelAdrss = tk.Label(m, text = 'Adress')
labelAdrss.grid(row = 0, column = 0,padx = 4, pady = 4)
labelPort = tk.Label(m, text = 'Port')
labelPort.grid(row = 1, column = 0,padx = 4, pady = 4)
buttonCloseServer = tk.Button(m, text='close server',width=25,command=close_server)
buttonCloseServer.grid(row = 1, column = 3,padx = 4, pady = 4)
buttonSend = tk.Button(m, text='connect',width=25,command= file_request)
buttonSend.grid(row = 0, column = 3,padx = 4, pady = 4)
buttonDestroy = tk.Button(m, text='close',width=25,command=m.destroy)
buttonDestroy.grid(row = 4, column = 3,padx = 4, pady = 4)
textConsole = tk.Text(m,width = 45, height = 5)
textConsole.grid(row = 2, column = 0,padx = 0, pady = 4, columnspan = 2)
m.mainloop()