-
Notifications
You must be signed in to change notification settings - Fork 0
/
transport.py
55 lines (42 loc) · 1.15 KB
/
transport.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
from tkinter import Tk
import socket
PORT = 3872
SELF = "one-ip-here"
OTHER = "the-other-ip-here"
def send(IP):
sender = socket.socket()
sender.connect((IP,PORT))
data = Tk().clipboard_get().encode()
sender.send(data)
sender.close()
def receive(IP):
receiver = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
receiver.bind((IP,PORT))
receiver.listen()
c, addr = receiver.accept()
data = c.recv(100000)
print(data)
clip = data.decode()
root = Tk()
root.withdraw()
root.clipboard_clear()
root.clipboard_append(clip)
print(addr)
c.close()
import PySimpleGUI as sg
sg.theme("Dark")
layout=[
[sg.Button("Send"), sg.Button("Receive"), sg.Button("Cancel")]
]
window = sg.Window("Share Clipboard", layout, size=(500,100), element_justification='c')
while True:
event, values = window.read()
if event == "Send":
print("sending...")
send(PC)
if event == "Receive":
print("receiving...")
receive(LAPTOP)
if event == sg.WIN_CLOSED or event == 'Cancel':
break
window.close()