-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew_client.py
105 lines (91 loc) · 2.66 KB
/
new_client.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
from appJar import gui
from roku import Roku
from pynput import keyboard
from pynput.keyboard import Key
import threading
roku = Roku('192.168.1.5')
def press(button):
if button == "Home":
roku.home()
elif button == "Go to Search":
roku.search()
elif button == "Back":
roku.back()
elif button == "OK":
roku.select()
elif button == "Settings":
roku.home()
roku.down()
roku.down()
roku.down()
roku.down()
roku.down()
roku.down()
roku.down()
roku.down()
roku.select()
elif button == "Submit":
userInput = app.getEntry("Send text:")
roku.literal(userInput)
elif button == "Backspace":
roku.backspace()
elif button == "⬆️":
roku.up()
elif button == "⬅️":
roku.left()
elif button == "➡️":
roku.right()
elif button == "⬇️":
roku.down()
elif button == "NETFLIX":
netflix.launch()
elif button == "SLING":
sling.launch()
elif button == "AMAZON":
amazon.launch()
else:
hbo.launch()
def rokuSubmitText():
userInput = app.getEntry("Send text:")
roku.literal(userInput)
# Keybindings
def on_press(key):
if(key==Key.left):
roku.left()
elif(key==Key.right):
roku.right()
elif(key==Key.down):
roku.down()
elif(key==Key.up):
roku.up()
elif(key==Key.enter):
rokuSubmitText()
def listenKeyboard():
with keyboard.Listener(on_press=on_press) as listener:
listener.join()
# daemon=True stops thread when gui is closed
keyboard_listener = threading.Thread(target=listenKeyboard, daemon=True)
keyboard_listener.start()
# Channel shortcuts
sling = roku['Sling TV']
netflix = roku['Netflix']
amazon = roku['Prime Video']
hbo = roku['HBO Max']
# End of backend code, just frontend from here on out
app = gui("Main", "1600x900")
app.addLabel("title", "RoPy Roku Client")
app.setLabelFg("title", "purple")
app.setLabelFont("title", size=28, family='Times')
app.addButtons(["Home", "Go to Search", "Back", "Settings"], press)
app.addLabelEntry("Send text:")
app.setLabelFont("Send text:", size=10)
app.addButtons(["Submit", "Backspace"], press)
app.addButtons(["⬆️"], press)
app.addButtons(["⬅️", "OK", "➡️"], press)
app.addButtons(["⬇️"], press)
app.addButtons(["NETFLIX", "SLING", "AMAZON", "HBO"], press)
app.setButtonBg("NETFLIX", "red")
app.setButtonBg("SLING", "yellow")
app.setButtonBg("AMAZON", "blue")
app.setButtonBg("HBO", "pink")
app.go()