From d3970b8b28a5245d926aa816ddf5cdc5300688ad Mon Sep 17 00:00:00 2001 From: gfdgd_xi <3025613752@qq.com> Date: Thu, 7 Jul 2022 14:35:44 +0800 Subject: [PATCH] =?UTF-8?q?1.7.0=E5=88=9D=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 2 +- __pycache__/getxmlimg.cpython-37.pyc | Bin 3183 -> 3183 bytes api/__pycache__/__init__.cpython-37.pyc | Bin 16047 -> 16047 bytes information.json | 9 +++- launch.sh | 3 ++ main.py | 54 ++++++++++++++---------- uengine-apk-builder | 18 ++++++-- uengine-runner-applist-launch.sh | 4 +- uengine-runner-update-bug | 21 +++++++-- 9 files changed, 78 insertions(+), 33 deletions(-) create mode 100755 launch.sh diff --git a/.idea/misc.xml b/.idea/misc.xml index a2e120d..60121c6 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/__pycache__/getxmlimg.cpython-37.pyc b/__pycache__/getxmlimg.cpython-37.pyc index aec1ea2423a0d0f4a03d5fff4ea6647f4382e078..f69713c0590290c592295f382f8915617ca3a563 100644 GIT binary patch delta 73 zcmaDa@m_+*iINxi<6g;VJNX881f%I>LmoQ->H!nO delta 73 zcmaDa@m_+*iI delta 20 acmZ2qyS|p&iIaria2)", "6、提供了 UEngine 运行器的 API(可以从项目地址中获取)", "7、补上遗漏的项目参与者“星空露光”,新加项目参与者“为什么您不喜欢熊出没和阿布呢”", + "", "V1.6.0:", "※1、更换了新的图标", "※2、支持程序的评分和查看分数详情的功能(如果炸了我的服务器,这个就作废了)", diff --git a/launch.sh b/launch.sh new file mode 100755 index 0000000..674905e --- /dev/null +++ b/launch.sh @@ -0,0 +1,3 @@ +#!/bin/bash +XDG_CURRENT_DESKTOP="Deepin" +$1 -platformtheme deepin "$@" diff --git a/main.py b/main.py index 1316fe0..3f85ac3 100755 --- a/main.py +++ b/main.py @@ -2,8 +2,8 @@ # 使用系统默认的 python3 运行 ########################################################################################### # 作者:gfdgd xi<3025613752@qq.com> -# 版本:1.6.2 -# 更新时间:2022年6月20日(要期末考试了) +# 版本:1.6.3 +# 更新时间:2022年07月07日(暑假了) # 感谢:anbox、deepin 和 UOS # 基于 Python3 的 tkinter 构建 # 更新:gfdgd xi<3025613752@qq.com>、actionchen<917981399@qq.com>、为什么您不喜欢熊出没和阿布呢 @@ -39,7 +39,6 @@ import tkinter.filedialog as filedialog import tkinter.simpledialog as simpledialog from getxmlimg import getsavexml -win = tk.Tk() # 创建窗口 # 卸载程序 def UninstallProgram(package: "apk 包名")->"卸载程序": @@ -333,19 +332,19 @@ def InstallRootUengineImage(): if not os.path.exists: os.mkdir("/tmp/uengine-runner") write_txt("/tmp/uengine-runner/install.sh", "sudo dpkg -i /tmp/uengine-runner/u*.deb\nsudo apt install -f") - threading.Thread(target=os.system, args=["deepin-terminal -C \"wget -P '/tmp/uengine-runner' 'https://hub.fastgit.xyz/gfdgd-xi/uengine-runner/releases/download/U1.2.15/uengine-android-image_1.2.15_amd64.deb' && pkexec bash '/tmp/uengine-runner/install.sh'\""]).start() + threading.Thread(target=os.system, args=[f"'{programPath}/launch.sh' deepin-terminal -C \"wget -P '/tmp/uengine-runner' 'https://hub.fastgit.xyz/gfdgd-xi/uengine-runner/releases/download/U1.2.15/uengine-android-image_1.2.15_amd64.deb' && pkexec bash '/tmp/uengine-runner/install.sh'\""]).start() def UengineUbuntuInstall(): - threading.Thread(target=os.system, args=["deepin-terminal -C \"bash '{}'\"".format(programPath + "/uengine-installer")]).start() + threading.Thread(target=os.system, args=[f"'{programPath}/launch.sh' deepin-terminal -C \"bash '{programPath + '/uengine-installer'}'\""]).start() def UbuntuInstallUengine(): - threading.Thread(target=os.system, args=["deepin-terminal -C \"bash '{}'\"".format(programPath + "/uengine-installer")]).start() + threading.Thread(target=os.system, args=[f"'{programPath}/launch.sh' deepin-terminal -C \"bash '{programPath + '/uengine-installer'}'\""]).start() def BuildRootUengineImage(): - threading.Thread(target=os.system, args=["deepin-terminal -C \"bash '{}'\"".format(programPath + "/root-uengine.sh")]).start() + threading.Thread(target=os.system, args=[f"'{programPath}/launch.sh' deepin-terminal -C \"bash '{programPath + '/root-uengine.sh'}'\""]).start() def ReinstallUengineImage(): - threading.Thread(target=os.system, args=["deepin-terminal -e ''pkexec apt reinstall uengine-android-image"]).start() + threading.Thread(target=os.system, args=[f"'{programPath}/launch.sh' deepin-terminal -e ''pkexec apt reinstall uengine-android-image -y"]).start() # 生成 uengine 启动文件到桌面 def BuildUengineDesktop(packageName: "软件包名", activityName: "activity", showName: "显示名称", iconPath: "程序图标所在目录", savePath:".desktop 文件保存路径")->"生成 uengine 启动文件到桌面": @@ -577,12 +576,12 @@ def OpenUengineUserData(): # 终端显示 adb 命令行 def AdbShellShowInTer(): os.system("adb connect 192.168.250.2:5555") - threading.Thread(target=os.system, args=["deepin-terminal -w ~ -e 'adb -s 192.168.250.2:5555 shell'"]).start() + threading.Thread(target=os.system, args=[f"'{programPath}/launch.sh' deepin-terminal -w ~ -e 'adb -s 192.168.250.2:5555 shell'"]).start() # 终端显示 adb top def AdbCPUAndRAWShowInTer(): os.system("adb connect 192.168.250.2:5555") - threading.Thread(target=os.system, args=["deepin-terminal -w ~ -e 'adb -s 192.168.250.2:5555 shell top'"]).start() + threading.Thread(target=os.system, args=[f"'{programPath}/launch.sh' deepin-terminal -w ~ -e 'adb -s 192.168.250.2:5555 shell top'"]).start() def UengineSettingShow(): threading.Thread(target=os.system, args=["/usr/bin/uengine launch --action=android.intent.action.MAIN --package=com.android.settings --component=com.android.settings.Settings"]).start() @@ -603,7 +602,7 @@ def AdbStartServer(): messagebox.showinfo(title="提示", message="完成!") def ReinstallUengine(): - threading.Thread(target=os.system, args=["deepin-terminal -C 'pkexec apt reinstall uengine uengine-android-image uengine-modules-dkms -y && notify-send -i uengine \"安装完毕!\"'"]).start() + threading.Thread(target=os.system, args=[f"'{programPath}/launch.sh' deepin-terminal -C 'pkexec apt reinstall uengine uengine-android-image uengine-modules-dkms -y && notify-send -i uengine \"安装完毕!\"'"]).start() def DelUengineCheck(): if not os.path.exists("/usr/share/uengine/uengine-check-runnable.sh"): @@ -680,7 +679,7 @@ def AllowOrDisallowUpdateAndroidApp(): messagebox.showinfo(title=langFile[lang]["Main"]["MainWindow"]["Information"]["Title"], message=langFile[lang]["Main"]["MainWindow"]["Answer"]["CompleteInformation"]) class SettingWindow(): - saveApkOption = tk.IntVar() + saveApkOption = None def ShowWindow(): setting = tk.Toplevel() setting.resizable(0, 0) @@ -761,7 +760,7 @@ zenity --info --text=\"更新完毕!\" --ellipsize except: traceback.print_exc() easygui.textbox(title="错误", msg="更新出现错误,无法继续更新!", text=traceback.format_exc()) - os.system("deepin-terminal -e pkexec bash /tmp/uengine-runner/update.sh") + os.system(f"'{programPath}/launch.sh' deepin-terminal -e pkexec bash /tmp/uengine-runner/update.sh") image = None class ApkInformation(): @@ -1251,11 +1250,7 @@ def showhelp(): y = (screen_height/2) - (winhigh/2) if not helpwindow.winfo_screenheight() > 1080: helpwindow.geometry(f"{winwith}x{winhigh}"+"+{:.0f}+{:.0f}".format(x, y)) - - style = ttkthemes.ThemedStyle(helpwindow) - style.set_theme("breeze") - - + Frmroot=ttk.Frame(helpwindow) FrmMenu = ttk.Frame(Frmroot) @@ -1335,7 +1330,20 @@ def showhelp(): print(windowflag) #helpwindow.mainloop() helpwindow.protocol("WM_DELETE_WINDOW", on_closing) - +# 读取主题 +try: + theme = not ("dark" in readtxt(get_home() + "/.gtkrc-2.0") and "gtk-theme-name=" in readtxt(get_home() + "/.gtkrc-2.0")) +except: + print("主题读取错误,默认使用浅色主题") + theme = True +if theme: + win = tk.Tk() + themes = ttkthemes.ThemedStyle(win) + themes.set_theme("breeze") +else: + import ttkbootstrap + style = ttkbootstrap.Style(theme="darkly") + win = style.master # 创建窗口 ########################### # 检查 UEngine 是否安装 ########################### @@ -1347,12 +1355,12 @@ if not os.path.exists("/usr/bin/uengine"): # Deepin/UOS 用户 if "deepin" in SystemVersion.lower() or "uos" in SystemVersion.lower(): if messagebox.askyesno(title="提示", message="您的电脑没有安装 UEngine,是否安装 UEngine 以便更好的使用\n安装完后重新启动该程序即可"): - os.system("deepin-terminal -C \"pkexec apt install uengine\"") + os.system(f"'{programPath}/launch.sh' deepin-terminal -C \"pkexec apt install uengine -y\"") sys.exit(0) # 非 Deepin/UOS 用户 else: if messagebox.askyesno(title="提示", message="您的电脑没有安装 UEngine,是否安装 UEngine 以便更好的使用\n这里将会使用 shenmo 提供的脚本进行安装\n安装完后重新启动该程序即可\n提示:无法保证此安装脚本安装的 UEngine 可以使用"): - os.system(f"deepin-terminal -C \"bash '{programPath}/uengine-installer'\"") + os.system(f"'{programPath}/launch.sh' deepin-terminal -C \"bash '{programPath}/uengine-installer'\"") sys.exit(0) # 重新显示窗口 win.wm_deiconify() @@ -1363,8 +1371,8 @@ if not os.path.exists("/usr/bin/uengine"): # 设置窗口 -style = ttkthemes.ThemedStyle(win) -style.set_theme("breeze") +#style = ttkthemes.ThemedStyle(win) +#style.set_theme("breeze") window = ttk.Frame(win) win.title(title) win.resizable(0, 0) diff --git a/uengine-apk-builder b/uengine-apk-builder index 6a963bd..b553d46 100755 --- a/uengine-apk-builder +++ b/uengine-apk-builder @@ -397,7 +397,20 @@ findApkHistory = list(json.loads(readtxt(get_home() + "/.config/uengine-runner/F ########################### # 窗口创建 ########################### -win = tk.Tk() +# 读取主题 +try: + theme = not ("dark" in readtxt(get_home() + "/.gtkrc-2.0") and "gtk-theme-name=" in readtxt(get_home() + "/.gtkrc-2.0")) +except: + print("主题读取错误,默认使用浅色主题") + theme = True +if theme: + win = tk.Tk() + themes = ttkthemes.ThemedStyle(win) + themes.set_theme("breeze") +else: + import ttkbootstrap + style = ttkbootstrap.Style(theme="darkly") + win = style.master # 创建窗口 qianZhui = tk.BooleanVar() @@ -422,9 +435,6 @@ textbox1.config(foreground='white', background='black') if len(sys.argv) > 1: combobox1.set(sys.argv[1]) # 设置窗口 -style = ttkthemes.ThemedStyle(win) -style.set_theme("breeze") -#win.attributes('-alpha', 0.5) win.title(title) win.resizable(0, 0) win.iconphoto(False, tk.PhotoImage(file=iconPath)) diff --git a/uengine-runner-applist-launch.sh b/uengine-runner-applist-launch.sh index 83d7a99..c2901f1 100755 --- a/uengine-runner-applist-launch.sh +++ b/uengine-runner-applist-launch.sh @@ -1,4 +1,6 @@ #!/bin/bash +cd `dirname $0` +dir=`pwd` FILE=/usr/bin/uengine if [ -f "$FILE" ]; then echo "$FILE 存在,正常打开菜单" @@ -13,7 +15,7 @@ else echo "此系统为 Deepin/UOS,使用 apt 安装" zenity --question --text="您还未安装 UEngine,是否现在安装?" --no-wrap if [[ $? = 0 ]]; then - deepin-terminal -C "pkexec apt install uengine" + "$dir/uengine-runner-applist-launch.sh" deepin-terminal -C "pkexec apt install uengine -y" fi else echo "非 Deepin/UOS 系统,使用 shenmo 提供的脚本安装\n暂未保证此安装脚本一定安装成功" diff --git a/uengine-runner-update-bug b/uengine-runner-update-bug index 84b7de7..e4e742b 100755 --- a/uengine-runner-update-bug +++ b/uengine-runner-update-bug @@ -46,6 +46,10 @@ def OpenGiteeIssues(): def OpenGithubIssues(): webbrowser.open_new_tab("https://github.com/gfdgd-xi/uengine-runner/issues") +# 获取用户主目录 +def get_home()->"获取用户主目录": + return os.path.expanduser('~') + ########################### # 程序信息 ########################### @@ -57,7 +61,20 @@ version = information["Version"] ########################### # 窗口创建 ########################### -window = tk.Tk() +# 读取主题 +try: + theme = not ("dark" in readtxt(get_home() + "/.gtkrc-2.0") and "gtk-theme-name=" in readtxt(get_home() + "/.gtkrc-2.0")) +except: + print("主题读取错误,默认使用浅色主题") + theme = True +if theme: + window = tk.Tk() + themes = ttkthemes.ThemedStyle(window) + themes.set_theme("breeze") +else: + import ttkbootstrap + style = ttkbootstrap.Style(theme="darkly") + window = style.master # 创建窗口 win = ttk.Frame() starValue = tk.StringVar() @@ -84,8 +101,6 @@ githubButton = ttk.Button(otherUpload, text="Github Issues", command=OpenGithubI updateButton = ttk.Button(win, text="提交", command=UpdateButtonClick) # 设置窗口 -style = ttkthemes.ThemedStyle(window) -style.set_theme("breeze") window.title("UEngine 运行器 {} 问题/建议反馈".format(version)) window.resizable(0, 0) window.iconphoto(False, tk.PhotoImage(file=iconPath))