Skip to content

Commit 4451fa9

Browse files
Responsive UI
1 parent 6aaca3e commit 4451fa9

File tree

2 files changed

+44
-16
lines changed

2 files changed

+44
-16
lines changed

Projects/TkinterGUI/ScrCpy_GUI.py

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ def volup():
4444
def voldown():
4545
os.system(f'adb -s {ip} shell input keyevent 25')
4646

47+
def submit(x):
48+
try:
49+
if x == '':
50+
os.system('keyevents.json')
51+
else:
52+
os.system(f'adb -s {ip} shell input keyevent {x}')
53+
except Exception as e:
54+
print(e)
55+
4756
def fun():
4857
key = num_list.get(num_list.curselection()[0])
4958
key = key.split(' : ')[0]
@@ -55,27 +64,46 @@ def fun():
5564
root.title("ScrCpy GUI")
5665
root.config(bg="gray")
5766

58-
num_list = Listbox(root, height=15, width=30)
59-
with open('keyevents.json') as f:
60-
data = json.load(f)
67+
try:
68+
rely3 = 0.7
69+
rely4 = 0.8
70+
rely5 = 0.9
71+
72+
num_list = Listbox(root, height=15, width=30)
73+
with open('keyevents.json') as f:
74+
data = json.load(f)
75+
76+
for i in data['key_events']:
77+
j = data['key_events'][i]
78+
k = j.split('adb shell input keyevent ')
79+
num_list.insert(k[1], f'{k[1]} : {i.split("key_")[1]}')
80+
81+
num_list.place(relx=0.5, rely=0.4, anchor='center')
82+
get_num_btn = Button(root, bg='green', text="Run ADB", command=fun)
83+
get_num_btn.place(relx=0.5, rely=0.1, anchor='center')
84+
85+
except:
86+
rely3 = 0.5
87+
rely4 = 0.6
88+
rely5 = 0.8
89+
90+
event = StringVar()
91+
btn1 = Entry(root, textvariable = event)
6192

62-
for i in data['key_events']:
63-
j = data['key_events'][i]
64-
k = j.split('adb shell input keyevent ')
65-
num_list.insert(k[1], f'{k[1]} : {i.split("key_")[1]}')
93+
btn1.insert(0, '209') # Open Music App
94+
btn1.place(relx=0.5, rely=0.1, anchor='center')
6695

67-
num_list.place(relx=0.5, rely=0.4, anchor='center')
68-
get_num_btn = Button(root, bg='green', text="Run ADB", command=fun)
69-
get_num_btn.place(relx=0.5, rely=0.1, anchor='center')
96+
btn2 = Button(root, bg='green', text = 'Keyevent', command=lambda: submit(event.get()))
97+
btn2.place(relx=0.5, rely=0.2, anchor='center')
7098

71-
VolumeUp = Button(root, text="Volume Up", command=volup)
72-
VolumeUp.place(relx=0.5, rely=0.7, anchor='center')
99+
btn3 = Button(root, text="Volume Up", command=volup)
100+
btn3.place(relx=0.5, rely=rely3, anchor='center')
73101

74-
VolumeDown = Button(root, text="Volume Down", command=voldown)
75-
VolumeDown.place(relx=0.5, rely=0.8, anchor='center')
102+
btn4 = Button(root, text="Volume Down", command=voldown)
103+
btn4.place(relx=0.5, rely=rely4, anchor='center')
76104

77-
Power = Button(root, bg='red', text="Power ON / OFF", command=power)
78-
Power.place(relx=0.5, rely=0.9, anchor='center')
105+
btn5 = Button(root, bg='red', text="Power ON / OFF", command=power)
106+
btn5.place(relx=0.5, rely=rely5, anchor='center')
79107
root.mainloop()
80108

81109

Projects/TkinterGUI/wallpaper.png

-75.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)