Skip to content

Commit

Permalink
finish & completed command with error callback
Browse files Browse the repository at this point in the history
  • Loading branch information
yohanesokta committed Jul 9, 2023
1 parent 21132e7 commit a8553d1
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 30 deletions.
Binary file modified __pycache__/runner.cpython-311.pyc
Binary file not shown.
86 changes: 61 additions & 25 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
import customtkinter
from PIL import Image
import subprocess
import os
import psutil
from user_data import *
from runner import mainRun


# 0.scrcpy.exe - default on runtime
# 1.fulscreen
# 2.audo forward
# 3.keep on
# 4.resulusi
# 5.frame rate
# 6.record
from runner import mainRun,OtgRunner

# INTIALIANZING
window = customtkinter.CTk()
Expand All @@ -25,8 +15,6 @@
# Open Config Or Write Config
config = load_data()



def cmdUpdate(add):
cmd.configure(state='normal')
cmd.insert("0.0",add)
Expand Down Expand Up @@ -78,14 +66,66 @@ def mirror_start():
global config
save_data(config)
cmdUpdate('Starting Screen Mirror\n')
mainRun(config)
mainRun(config,window)

def option(btn,name):
config.set('User',name,btn.get())
print('update')
cmdUpdate("setting updated { "+ str(btn.get()) + " }\n")

def otgM():
OtgRunner('mouse',window)
def otgMK():
OtgRunner('key',window)

#TOP LEVEL

def otgConnect():
top = customtkinter.CTkToplevel()
lebar = 295
tinggi = 150
Width = window.winfo_screenwidth()
Height = window.winfo_screenheight()
pos_x = int((Width/2) - (lebar/2))
pos_y = int((Height/2) - (tinggi/2) - 50)
top.geometry(f"{lebar}x{tinggi}+{pos_x}+{pos_y}")
top.resizable(0,0)
top.title('Select - OTG')
top.focus_force()
top.lift()
top.grab_set()

mouse = customtkinter.CTkButton(
master=top,
width=140,
height=140,
fg_color='#1883D5',
hover_color='#0088FF',
text='',
image=customtkinter.CTkImage(Image.open('./asset/mouse.png'),size=(80,82)),
command=otgM
)
mouse.place(x=5,y=5)

mouse_keyboard = customtkinter.CTkButton(
master=top,
width=140,
height=140,
fg_color='green',
hover_color='#60B060',
text='',
image=customtkinter.CTkImage(Image.open('./asset/key.png'),size=(80,74)),
command=otgMK
)
mouse_keyboard.place(x=150,y=5)
# --------------------------------------
# End TOP LEVE:
# --------------------------------------


# Window Wiget ------------------------


navigation_frame = customtkinter.CTkFrame(
master=window,
width=480,
Expand Down Expand Up @@ -150,7 +190,8 @@ def option(btn,name):
width=220,
height=80,
text='Device Miror',
image=otg_icon
image=otg_icon,
command=otgConnect
).place(x=10,y=167.5)

color_frame2 = "#A8CDEA"
Expand All @@ -174,7 +215,8 @@ def option(btn,name):
values=[
'480p',
'720p',
'1080p'
'1080p',
'Unset'
],
command=lambda event: option(res_conf,'res'),
bg_color=color_frame2
Expand Down Expand Up @@ -272,7 +314,6 @@ def option(btn,name):
cmd.unbind()

image_prev = customtkinter.CTkImage(light_image=Image.open('./asset/l_asset_1.png'),size=(460,180))

image_canvas = customtkinter.CTkButton(
master=window,
image=image_prev,
Expand All @@ -282,16 +323,11 @@ def option(btn,name):
height=180,
)
image_canvas.place(x=0,y=265)
# test
# s = subprocess.check_output("scrcpy.exe", shell = True)
# print(s.decode("utf-8"))

# p = subprocess.Popen(["scrcpy.exe"],stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
# output, errors = p.communicate()

# print(output)

# test
# --------------------------------------
# End Windows Wiget
# --------------------------------------

# Start Checking Adb
process = 'adb.exe'
Expand Down
Binary file added asset/mouse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 22 additions & 4 deletions runner.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import subprocess
from tkinter import messagebox
from pathlib import Path
home = str(Path.home())
home += '\\videos\\MirrorRec'
def mainRun(args):


def mainRun(args,window):
global home
lib = 'User'
exec = ['scrcpy.exe']
Expand Down Expand Up @@ -34,7 +37,22 @@ def mainRun(args):
exec += ['-r',home + '.mp4']
case 'Record (.mkv)':
exec += ['-r',home + '.mkv']

print(home)
print(exec)
subprocess.Popen(exec,shell=True,cwd='Runtime')
window.withdraw()
try:
grepOut = subprocess.check_output(exec, shell=True,cwd='Runtime')
except subprocess.CalledProcessError as grepexc:
messagebox.showerror('Program Gak iso jalan', 'Please check cable or turn on USB Debugging')
window.deiconify()


# function otg

def OtgRunner(hid,window):
exec = ['scrcpy.exe','--otg','-M']
if hid == 'key':
exec += ['-K']
try:
prog = subprocess.check_output(exec,shell=True,cwd='Runtime')
except subprocess.CalledProcessError as progexc:
messagebox.showerror('Program Gak iso jalan', 'Please check cable or turn on USB Debugging')
2 changes: 1 addition & 1 deletion user_config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ fullscreen = False
audio = False
keepon = False
res = 480p
mxfps = 50 Fps
mxfps = 60 Fps
record = Record (.mkv)

0 comments on commit a8553d1

Please sign in to comment.