-
Notifications
You must be signed in to change notification settings - Fork 0
/
guiTest.py
115 lines (105 loc) · 2.71 KB
/
guiTest.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.floatlayout import FloatLayout
from kivy.config import Config
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.logger import Logger
from kivy.uix.progressbar import ProgressBar
import socket, os, subprocess, time, threading
import server, client
from os.path import expanduser
Config.set('graphics', 'width', '300')
Config.set('graphics', 'height', '300')
Builder.load_string("""
<HomeScreen>:
canvas.before:
Color:
rgba: 42,150,168, 0.8
Rectangle:
pos: self.pos
size: self.size
FloatLayout:
Image:
pos_hint: {'x': .43, 'y': .6}
size_hint: None, None
source: './mir-r.png'
Button:
text: "Host"
pos_hint: {'x': .30, 'y': .4}
size_hint: .2, .1
on_press: root.manager.current = 'host'
Button:
text: "Client"
pos_hint: {'x': .51, 'y': .4}
size_hint: .2, .1
on_press: root.manager.current = 'client'
<HostScreen>:
on_enter: root.hostCon()
on_enter: root.load()
FloatLayout:
Button:
text: "Back"
pos_hint: {'x': .1, 'y': .8}
size_hint: .2, .1
on_press: root.load()
on_press: root.manager.current = 'home'
Label:
text: root.getIP()
pos_hint: {'x': .30, 'y': .5}
size_hint: .4, .2
ProgressBar:
id: bar
max: 1000
value: 1000
Label:
text: "Hosting"
pos_hint: {'x': .30, 'y': .3}
size_hint: .4, .2
<ClientScreen>:
FloatLayout:
Button:
text: "Back"
pos_hint: {'x': .1, 'y': .8}
size_hint: .2, .1
on_press: root.manager.current = 'home'
Button:
text: "Connect"
pos_hint: {'x': .2, 'y': .4}
size_hint: .2, .1
on_press: root.clientCon(ip.text)
TextInput:
id: ip
pos_hint: {'x': .41, 'y': .4}
size_hint: .4, .1
""")
class HomeScreen(Screen):
pass
class HostScreen(Screen):
def hostCon(fk):
output = []
server.getOpenData(output)
host = threading.Thread(target=server.runHost, args=[output])
host.start()
def load(self):
screen = HostScreen()
screen.ids['bar'].value = 1000
pb = ProgressBar()
pb.value = 1000
def getIP(self):
return server.getIP()
pass
class ClientScreen(Screen):
def clientCon(fk, ip):
guest = threading.Thread(target=client.runClient, args=[ip])
guest.start()
pass
sm = ScreenManager()
sm.add_widget(HomeScreen(name='home'))
sm.add_widget(HostScreen(name='host'))
sm.add_widget(ClientScreen(name='client'))
class MirrorApp(App):
def build(self):
self.icon = './mir-r.png'
return sm
if __name__ == '__main__':
MirrorApp().run()