一点点东西

This commit is contained in:
gfdgd xi 2021-10-26 20:19:42 +08:00
parent ad5f08ca38
commit 4f0fafbf17
15 changed files with 762 additions and 58 deletions

129
Android X86/main.py Normal file
View File

@ -0,0 +1,129 @@
import os
import sys
import threading
#import ttkthemes
import tkinter as tk
import tkinter.ttk as ttk
import tkinter.messagebox as messagebox
class AddVirtualMachine():
def ShowWindow():
messgae = tk.Toplevel()
chooseImageString = tk.StringVar()
chooseImageString.set("请选择……")
nameTips = tk.Label(messgae, text="虚拟机名称")
nameEntry = tk.Entry(messgae, width=50)
memoryTips = tk.Label(messgae, text="虚拟机内存分配")
memoryDefultValue = tk.Checkbutton(messgae, text="默认值")
memoryValue = tk.Scale(messgae, from_=1, orient=tk.HORIZONTAL)
chooseImageTips = tk.Label(messgae, text="选择虚拟机镜像:")
chooseImage = tk.OptionMenu(messgae, chooseImageString, [""])
quicklyFasterSpeed = tk.Checkbutton(messgae, text="启动 kvm 加速")
tipsThings = tk.Label(messgae, text="虚拟机备注:")
tipsThingsTips = tk.Text(messgae, height=5, width=50)
controlFrame = tk.Frame(messgae)
cancal = tk.Button(controlFrame ,text="取消")
ok = tk.Button(controlFrame, text="确定")
messgae.title("添加 Android X86 虚拟机")
messgae.resizable(0, 0)
memoryValue.set(33)
cancal.grid(row=0, column=0)
ok.grid(row=0, column=1)
nameTips.grid(row=0, column=0)
nameEntry.grid(row=0, column=1, columnspan=3)
memoryTips.grid(row=1, column=0)
memoryDefultValue.grid(row=1, column=1)
memoryValue.grid(row=1, column=2)
chooseImageTips.grid(row=2, column=0)
chooseImage.grid(row=2, column=1)
quicklyFasterSpeed.grid(row=2, column=2)
tipsThings.grid(row=3, column=0)
tipsThingsTips.grid(row=3, column=1, columnspan=3, rowspan=2, sticky=tk.W)
controlFrame.grid(row=5, column=3, sticky=tk.E)
#controlFrame.grid(row=5, column=2)
messgae.mainloop()
class DelVirtualMachine():
def Tips():
if messagebox.askokcancel(title="提示", message="你确定要删除此虚拟机吗?\n删除后将无法恢复!"):
messagebox.showinfo(title="提示", message="删除完毕!")
class AddVirtualImage():
def ShowWindow():
message = tk.Toplevel()
urlImageDownloadTips = tk.Label(message, text="可下载镜像:")
urlImageDownloadList = ttk.Treeview(message)
addImage = tk.Button(message, text="")
delImage = tk.Button(message, text="")
ImageTips = tk.Label(message, text="已下载镜像:")
ImageList = ttk.Treeview(message)
ok = tk.Button(message, text="确定")
message.title("下载新的镜像")
message.resizable(0, 0)
urlImageDownloadTips.grid(row=0, column=0, sticky=tk.W)
urlImageDownloadList.grid(row=1, column=0, rowspan=4)
addImage.grid(row=2, column=1)
delImage.grid(row=3, column=1)
ImageTips.grid(row=0, column=2, sticky=tk.W)
ImageList.grid(row=1, column=2, rowspan=4)
ok.grid(row=5, column=2, sticky=tk.E)
message.mainloop()
class SettingVirtualMachine():
pass
def RunVirtualMachine():
threading.Thread(target=os.system, args=["kvm --cdrom {} --hda {} -m {}G".format("", "", "")]).start()
window = tk.Tk()
virtualMachineList = ttk.Treeview(window)
addVirtualMachine = tk.Button(window, text="", command=AddVirtualMachine.ShowWindow)
delVirtualMachine = tk.Button(window, text="", command=DelVirtualMachine.Tips)
addVirtualMachineImage = tk.Button(window, text="", command=AddVirtualImage.ShowWindow)
settingVirtualMachine = tk.Button(window, text="⚙️")
runVirtualMachine = tk.Button(window, text="", command=RunVirtualMachine)
tipsThings = tk.Text(window, height=5, width=30)
menu = tk.Menu(window)
programMenu = tk.Menu(menu, tearoff=0)
yuanMenu = tk.Menu(menu, tearoff=0)
menu.add_cascade(label="程序", menu=programMenu)
menu.add_cascade(label="", menu=yuanMenu)
programMenu.add_command(label="退出程序", command=sys.exit)
yuanMenu.add_command(label="更换源")
yuanMenu.add_command(label="修改默认源")
#window.configure(bg="white")
#ttkthemes.ThemedStyle(window).set_theme("ubuntu")
window.title("Android X86 Runner")
window.resizable(0, 0)
window.config(menu=menu)
runVirtualMachine.configure(foreground="green")
#tipsThings.configure(bg="white", foreground="black", state=tk.DISABLED)
virtualMachineList.grid(row=0, column=0, rowspan=3)
addVirtualMachine.grid(row=0, column=1)
delVirtualMachine.grid(row=0, column=2)
addVirtualMachineImage.grid(row=0, column=3)
settingVirtualMachine.grid(row=0, column=4)
runVirtualMachine.grid(row=0, column=5)
tipsThings.grid(row=2, column=1, columnspan=5, sticky=tk.W)
window.mainloop()

View File

@ -5,6 +5,6 @@ Homepage: [https://gitee.com/gfdgd-xi/uengine-runner, https://github.com/gfdgd-x
Architecture: all
Priority: optional
Conflicts: com.gitee.uengine.runner.spark, spark-uengine-apk-builder
Depends: python3, python3-tk, python3-pip, aapt, uengine, python3-setuptools, deepin-terminal, curl, python3-pil, python3-pil.imagetk, python3-requests, adb, translate-shell
Depends: python3, python3-tk, python3-pip, aapt, uengine, python3-setuptools, deepin-terminal, curl, python3-pil, python3-pil.imagetk, python3-requests, adb, translate-shell, python3-xlib
Description: UEngine Runner for deepin and UOS

View File

@ -1,14 +1,3 @@
#!/bin/sh
# 删除软链接
rm -fv /usr/bin/uengine-runner
rm -fv /usr/bin/uengine-apk-builder
rm -fv /usr/bin/uengine-app-uninstall
rm -fv /usr/bin/uengine-app-install
rm -fv /usr/bin/uengine-clean
rm -fv /usr/bin/uengine-runner-about
rm -fv /usr/bin/uengine-keyboard
rm -fv /usr/bin/uengine-useadb
rm -fv /usr/bin/uengine-runner-launch.sh
rm -fv /usr/bin/uengine-runner-update-bug
# 刷新图标缓存
gtk-update-icon-cache /usr/share/icons/bloom

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
#########################################
# 版本1.4.0
# 更新时间2021年08月26日
# 版本1.5.1
# 更新时间2021年10月06日
# Need: unix, python3-tk, python3-pip, pymouse, keyboard
#########################################
import os
@ -57,8 +57,8 @@ def Mouse(key):
print(keybo[key.name]["MousePlace"])
pyautogui.FAILSAFE = False
#os.system(programPath + "/mouse.py {} {}".format(keybo[key.name]["MousePlace"][0], keybo[key.name]["MousePlace"][1]))
#pyautogui.click(keybo[key.name]["MousePlace"][0], keybo[key.name]["MousePlace"][1])
pyautogui.click(1500, 800)
pyautogui.click(keybo[key.name]["MousePlace"][0], keybo[key.name]["MousePlace"][1])
#pyautogui.click(1500, 800)
#m.click(keybo[key.name]["MousePlace"][0],keybo[key.name]["MousePlace"][1])
def Setting(key):

Binary file not shown.

BIN
kbox/icon.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

21
kbox/information.json Executable file
View File

@ -0,0 +1,21 @@
{
"Url": [
"https://gitee.com/gfdgd-xi/uengine-runner",
"https://github.com/gfdgd-xi/uengine-runner"
],
"Version": "1.0.0 For arm64",
"System": "Linuxdeepin/UOS",
"Tips": [
"提示:",
""
],
"Update": [
""
],
"Use": [
""
],
"Time": "2021年10月17日",
"Contribute": ["gfdgd xi<3025613752@qq.com>",
"actionchen<917981399@qq.com>"]
}

113
kbox/kbox-runner-update-bug Executable file
View File

@ -0,0 +1,113 @@
#!/usr/bin/env python3
import os
import json
import base64
import requests
import ttkthemes
import traceback
import webbrowser
import tkinter as tk
import tkinter.ttk as ttk
import tkinter.messagebox as messagebox
import urllib.parse as parse
# 读取文本文档
def readtxt(path: "路径")->"读取文本文档":
f = open(path, "r") # 设置文件对象
str = f.read() # 获取内容
f.close() # 关闭文本对象
return str # 返回结果
def Update(name, stars, contact, things, version):
# post 内容
data = {
"Name": name,
"Starts": stars,
"Contact": contact,
"Things": things,
"Version": version
}
try:
messagebox.showinfo(message=requests.post(parse.unquote(base64.b64decode("aHR0cCUzQS8vZ2ZkZ2R4aS5xaWNwLnZpcC91ZW5naW5lL2J1Zy91cGxvYWQucGhw").decode("utf-8")), data=data).text)
except:
traceback.print_exc()
messagebox.showerror(title="错误", message="服务器疑似出现错误,可以进行以下尝试:①多尝试几次;②使用其他反馈途径\n错误信息{}".format(traceback.format_exc()))
def UpdateButtonClick():
#判断是否为空
if nameThings.get() == "" or starValue.get() == "" or contactThings.get() == "" or updateThings.get(1.0, "end").replace(" ", "").replace("\n", "") == "":
messagebox.showerror(title="错误", message="反馈信息未填写完整!")
return
Update(name=nameThings.get(), stars=starValue.get(), contact=contactThings.get(), things=updateThings.get(1.0, "end"), version=version)
def OpenGiteeIssues():
webbrowser.open_new_tab("https://gitee.com/gfdgd-xi/uengine-runner/issues")
def OpenGithubIssues():
webbrowser.open_new_tab("https://github.com/gfdgd-xi/uengine-runner/issues")
###########################
# 程序信息
###########################
iconPath = "{}/icon.png".format(os.path.split(os.path.realpath(__file__))[0])
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
information = json.loads(readtxt(programPath + "/information.json"))
version = information["Version"]
###########################
# 窗口创建
###########################
window = tk.Tk()
win = ttk.Frame()
starValue = tk.StringVar()
starValue.set("5分")
name = ttk.Label(win, text="你的昵称:")
nameThings = ttk.Entry(win, width=25)
contact = ttk.Label(win, text="联系方式:")
contactThings = ttk.Entry(win, width=25)
star = ttk.Label(win, text="评分:")
starMenu = ttk.OptionMenu(win, starValue, "5分", "5分", "4分", "3分", "2分", "1分")
updateThingsTips = ttk.Label(win, text="反馈内容(支持 Markdown 格式):")
updateThings = tk.Text(win)
otherUpload = ttk.Frame(win)
# 所属内容
tips = ttk.Label(otherUpload, text="如果无法正常反馈,可以用其他方式反馈:")
giteeButton = ttk.Button(otherUpload, text="Gitee Issues", command=OpenGiteeIssues)
githubButton = ttk.Button(otherUpload, text="Github Issues", command=OpenGithubIssues)
updateButton = ttk.Button(win, text="提交", command=UpdateButtonClick)
# 设置窗口
style = ttkthemes.ThemedStyle(window)
style.set_theme("breeze")
window.title("KBox 运行器 {} 问题/建议反馈".format(version))
window.resizable(0, 0)
window.iconphoto(False, tk.PhotoImage(file=iconPath))
tips.grid(row=0, column=0)
giteeButton.grid(row=0, column=1)
githubButton.grid(row=0, column=2)
name.grid(row=0, column=0)
nameThings.grid(row=0, column=1)
contact.grid(row=0, column=2)
contactThings.grid(row=0, column=3)
star.grid(row=0, column=4)
starMenu.grid(row=0, column=5)
updateThingsTips.grid(row=1, column=0, columnspan=2)
updateThings.grid(row=2, column=0, columnspan=6)
otherUpload.grid(row=3, column=0, columnspan=4)
updateButton.grid(row=3, column=5)
win.pack(expand="yes", fill="both")
window.mainloop()

482
kbox/main.py Executable file
View File

@ -0,0 +1,482 @@
#!/usr/bin/env python3
# 使用系统默认的 python3 运行
###########################################################################################
# 作者gfdgd xi<3025613752@qq.com>
# 版本1.5.2
# 更新时间2021年10月16日国庆了
# 感谢kbox 和 UOS
# 基于 Python3 的 tkinter 构建
# 更新gfdgd xi<3025613752@qq.com>、actionchen<917981399@qq.com>
###########################################################################################
#################
# 引入所需的库
#################
import os
import sys
import time
import json
import shutil
import zipfile
import traceback
import threading
import ttkthemes
import webbrowser
import subprocess
import tkinter as tk
import tkinter.ttk as ttk
import tkinter.messagebox as messagebox
import tkinter.filedialog as filedialog
temppath=""
def FindApk()->"浏览窗口":
path = filedialog.askopenfilename(title="选择 Apk", filetypes=[("APK 文件", "*.apk"), ("所有文件", "*.*")], initialdir=json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApk.json"))["path"])
global temppath
temppath = path
print("apk path is find:" + path)
if path != "" and path != "()":
try:
ComboInstallPath.set(path)
write_txt(get_home() + "/.config/kbox-runner/FindApk.json", json.dumps({"path": os.path.dirname(path)})) # 写入配置文件
except:
pass
# 安装应用
def InstallApk(path: "apk 路径", quit: "是否静默安装" = False):
try:
print("start install apk")
global findApkHistory
commandReturn = GetCommandReturn("pkexec android-appmgr.sh install '{}'".format(path))
print(commandReturn)
print("start install apk1")
print("\nprint install complete")
if quit:
print(commandReturn)
return
messagebox.showinfo(title="提示", message="操作完成!")
findApkHistory.append(ComboInstallPath.get())
ComboInstallPath['value'] = findApkHistory
write_txt(get_home() + "/.config/kbox-runner/FindApkHistory.json", str(json.dumps(ListToDictionary(findApkHistory)))) # 将历史记录的数组转换为字典并写入
except:
traceback.print_exc()
messagebox.showerror(title="错误", message=traceback.format_exc())
DisabledAndEnbled(False)
# 安装按钮事件
def Button3Install():
if ComboInstallPath.get() is "" or not os.path.exists(ComboInstallPath.get()):
messagebox.showerror(title="提示", message="信息没有填写完整或错误,无法继续安装 APK")
return
DisabledAndEnbled(True)
threading.Thread(target=InstallApk, args=(ComboInstallPath.get(),)).start()
# 禁用或启动所有控件
def DisabledAndEnbled(choose: "启动或者禁用")->"禁用或启动所有控件":
userChoose = {True: tk.DISABLED, False: tk.NORMAL}
a = userChoose[choose]
ComboInstallPath.configure(state=a)
BtnFindApk.configure(state=a)
BtnInstall.configure(state=a)
BtnShowUengineApp.configure(state=a)
LabApkPath.configure(state=a)
# 需引入 subprocess
# 运行系统命令并获取返回值
def GetCommandReturn(cmd: "命令")->"运行系统命令并获取返回值":
# cmd 是要获取输出的命令
return subprocess.getoutput(cmd)
def GetSystemVersion():
systemInformation = readtxt("/etc/os-release")
for systemInformation in systemInformation.split('\n'):
if "PRETTY_NAME=" in systemInformation:
return systemInformation.replace("PRETTY_NAME=", "").replace('"', '')
# 打开所有窗口事件
def Button5Click():
threading.Thread(target=OpenUengineProgramList).start()
# 打开“uengine 所有程序列表”
def OpenUengineProgramList()->"打开“uengine 所有程序列表”":
os.system("uengine launch --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity")
# 打开程序官网
def OpenProgramURL()->"打开程序官网":
webbrowser.open_new_tab(programUrl)
# 重启本应用程序
def ReStartProgram()->"重启本应用程序":
python = sys.executable
os.execl(python, python, * sys.argv)
# 清理历史记录
def CleanProgramHistory()->"清理历史记录":
try:
if messagebox.askokcancel(title="警告", message="删除后将无法恢复,你确定吗?\n删除后软件将会自动重启。"):
shutil.rmtree(get_home() + "/.config/kbox-runner")
ReStartProgram()
except:
traceback.print_exc()
messagebox.showerror(title="错误", message=traceback.format_exc())
# 获取用户主目录
def get_home()->"获取用户主目录":
return os.path.expanduser('~')
# 获取用户桌面目录
def get_desktop_path()->"获取用户桌面目录":
for line in open(get_home() + "/.config/user-dirs.dirs"): # 以行来读取配置文件
desktop_index = line.find("XDG_DESKTOP_DIR=\"") # 寻找是否有对应项,有返回 0没有返回 -1
if desktop_index != -1: # 如果有对应项
break # 结束循环
if desktop_index == -1: # 如果是提前结束,值一定≠-1如果是没有提前结束值一定-1
return -1
else:
get = line[17:-2] # 截取桌面目录路径
get_index = get.find("$HOME") # 寻找是否有对应的项,需要替换内容
if get != -1: # 如果有
get = get.replace("$HOME", get_home()) # 则把其替换为用户目录(~)
return get # 返回目录
# 数组转字典
def ListToDictionary(list: "需要转换的数组")->"数组转字典":
dictionary = {}
for i in range(len(list)):
dictionary[i] = list[i]
return dictionary
# 读取文本文档
def readtxt(path: "路径")->"读取文本文档":
f = open(path, "r") # 设置文件对象
str = f.read() # 获取内容
f.close() # 关闭文本对象
return str # 返回结果
# 写入文本文档
def write_txt(path: "路径", things: "内容")->"写入文本文档":
TxtDir = os.path.dirname(path)
print(TxtDir)
if not os.path.exists(TxtDir):
os.makedirs(TxtDir,exist_ok=True)
file = open(path, 'w', encoding='UTF-8') # 设置文件对象
file.write(things) # 写入文本
file.close() # 关闭文本对象
# 获取 aapt 的所有信息
def GetApkInformation(apkFilePath: "apk 所在路径")->"获取 aapt 的所有信息":
return GetCommandReturn("aapt dump badging '{}'".format(apkFilePath))
# 获取 apk Activity
def GetApkActivityName(apkFilePath: "apk 所在路径")->"获取 apk Activity":
info = GetApkInformation(apkFilePath)
for line in info.split('\n'):
if "launchable-activity" in line:
line = line[0: line.index("label='")]
line = line.replace("launchable-activity: ", "")
line = line.replace("'", "")
line = line.replace(" ", "")
line = line.replace("name=", "")
line = line.replace("label=", "")
line = line.replace("icon=", "")
return line
# 获取 apk 包名
def GetApkPackageName(apkFilePath: "apk 所在路径")->"获取 apk 包名":
info = GetApkInformation(apkFilePath)
for line in info.split('\n'):
if "package:" in line:
line = line[0: line.index("versionCode='")]
line = line.replace("package:", "")
line = line.replace("name=", "")
line = line.replace("'", "")
line = line.replace(" ", "")
return line
# 获取软件的中文名称
def GetApkChineseLabel(apkFilePath)->"获取软件的中文名称":
info = GetApkInformation(apkFilePath)
for line in info.split('\n'):
if "application-label:" in line:
line = line.replace("application-label:", "")
line = line.replace("'", "")
return line
# 保存apk图标
def SaveApkIcon(apkFilePath, iconSavePath)->"保存 apk 文件的图标":
try:
info = GetApkInformation(apkFilePath)
for line in info.split('\n'):
if "application:" in line:
xmlpath = line.split(":")[-1].split()[-1].split("=")[-1].replace("'","")
if xmlpath.endswith('.xml'):
xmlsave = getsavexml()
print(xmlpath)
xmlsave.savexml(apkFilePath,xmlpath,iconSavePath)
else:
zip = zipfile.ZipFile(apkFilePath)
iconData = zip.read(xmlpath)
with open(iconSavePath, 'w+b') as saveIconFile:
saveIconFile.write(iconData)
except:
traceback.print_exc()
print("Error, show defult icon")
shutil.copy(programPath + "/defult.png", iconSavePath)
# 获取用户主目录
def get_home()->"获取用户主目录":
return os.path.expanduser('~')
def UengineRunnerBugUpload():
threading.Thread(target=os.system, args=[programPath + "/kbox-runner-update-bug"]).start()
def GetApkVersion(apkFilePath):
info = GetApkInformation(apkFilePath)
for line in info.split('\n'):
if "package:" in line:
if "compileSdkVersion='" in line:
line = line.replace(line[line.index("compileSdkVersion='"): -1], "")
if "platform" in line:
line = line.replace(line[line.index("platform"): -1], "")
line = line.replace(line[0: line.index("versionName='")], "")
line = line.replace("versionName='", "")
line = line.replace("'", "")
line = line.replace(" ", "")
return line
###########################
# 程序信息
###########################
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
information = json.loads(readtxt(programPath + "/information.json"))
programUrl = information["Url"][0]
version = information["Version"]
goodRunSystem = information["System"]
aaptVersion = GetCommandReturn("aapt version")
SystemVersion = GetSystemVersion()
about = '''介绍 :一个基于 Python3 的 tkinter 制作的 KBox 运行器在新版本Deepin/UOS发布后可以在应用商店安装部分官方已适配的安卓应用对爱好者来说不能自己安装APK软件包始终差点意思本程序可以为UOS上的KBox安卓运行环境安装自定义APK软件包并能发送安装的APK包启动菜单到桌面或系统菜单。
版本 {}
适用平台 {}
Tk 版本 :{}
程序官网 {}
系统版本 :{}
©2021-{}'''.format(version, goodRunSystem, tk.TkVersion, programUrl, SystemVersion, time.strftime("%Y"))
tips = "\n".join(information["Tips"])
updateThingsString = "\n".join(information["Update"])
title = "KBox 安装器 {}".format(version)
updateTime = information["Time"]
updateThings = "{} 更新内容:\n{}\n更新时间:{}".format(version, updateThingsString, updateTime, time.strftime("%Y"))
iconPath = "{}/icon.png".format(os.path.split(os.path.realpath(__file__))[0])
desktop = programPath + "/UengineAndroidProgramList.desktop"
desktopName = "UengineAndroidProgramList.desktop"
contribute = "\n".join(information["Contribute"])
###########################
# 加载配置
###########################
if not os.path.exists("{}/.local/share/applications/uengine/".format(get_home())):
os.makedirs("{}/.local/share/applications/uengine/".format(get_home()))
if not os.path.exists(get_home() + "/.config/uengine-runner"): # 如果没有配置文件夹
os.makedirs(get_home() + "/.config/uengine-runner") # 创建配置文件夹
if not os.path.exists(get_home() + "/.config/uengine-runner/FindApkHistory.json"): # 如果没有配置文件
write_txt(get_home() + "/.config/uengine-runner/FindApkHistory.json", json.dumps({})) # 创建配置文件
if not os.path.exists(get_home() + "/.config/uengine-runner/FindApkNameHistory.json"): # 如果没有配置文件
write_txt(get_home() + "/.config/uengine-runner/FindApkNameHistory.json", json.dumps({})) # 创建配置文件
if not os.path.exists(get_home() + "/.config/uengine-runner/FindApkActivityHistory.json"): # 如果没有配置文件
write_txt(get_home() + "/.config/uengine-runner/FindApkActivityHistory.json", json.dumps({})) # 创建配置文件
if not os.path.exists(get_home() + "/.config/uengine-runner/FindUninstallApkHistory.json"): # 如果没有配置文件
write_txt(get_home() + "/.config/uengine-runner/FindUninstallApkHistory.json", json.dumps({})) # 创建配置文件
if not os.path.exists(get_home() + "/.config/uengine-runner/FindApkName.json"): # 如果没有配置文件
write_txt(get_home() + "/.config/uengine-runner/FindApkName.json", json.dumps({"path": "~"})) # 写入(创建)一个配置文件
if not os.path.exists(get_home() + "/.config/uengine-runner/FindApk.json"): # 如果没有配置文件
write_txt(get_home() + "/.config/uengine-runner/FindApk.json", json.dumps({"path": "~"})) # 写入(创建)一个配置文件
if not os.path.exists(get_home() + "/.config/uengine-runner/FindUninstallApk.json"): # 如果没有配置文件
write_txt(get_home() + "/.config/uengine-runner/FindUninstallApk.json", json.dumps({"path": "~"})) # 写入(创建)一个配置文件
if not os.path.exists(get_home() + "/.config/uengine-runner/SaveApkIcon.json"): # 如果没有配置文件
write_txt(get_home() + "/.config/uengine-runner/SaveApkIcon.json", json.dumps({"path": "~"})) # 写入(创建)一个配置文件
if not os.path.exists(get_home() + "/.config/uengine-runner/SaveApk.json"): # 如果没有配置文件
write_txt(get_home() + "/.config/uengine-runner/SaveApk.json", json.dumps({"path": "~"})) # 写入(创建)一个配置文件
###########################
# 设置变量
###########################
findApkHistory = list(json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkHistory.json")).values())
findApkNameHistory = list(json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkNameHistory.json")).values())
findApkActivityHistory = list(json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkActivityHistory.json")).values())
# add sub window
#添加窗口开启关闭开关,防止重复开启
windowflag = "close"
def showhelp():
#define window and frame and button label
#
global windowflag
if windowflag == "close":
helpwindow=tk.Toplevel()
helpwindow.resizable(0, 0)
helpwindow.title("帮助")
helpwindow.iconphoto(False, tk.PhotoImage(file=iconPath))
# get screen width and height
screen_width = helpwindow.winfo_screenwidth()
screen_height = helpwindow.winfo_screenheight()
# calculate position x and y coordinates 假设主窗口大小固定 570x236像素 ,设置窗口位置为屏幕中心。
winwith=550
winhigh=700
x = (screen_width/2) - (winwith/2)
y = (screen_height/2) - (winhigh/2)
helpwindow.geometry("550x700"+"+{:.0f}+{:.0f}".format(x, y))
style = ttkthemes.ThemedStyle(helpwindow)
style.set_theme("breeze")
Frmroot=ttk.Frame(helpwindow)
FrmMenu = ttk.Frame(Frmroot)
FrmText = ttk.Frame(Frmroot)
LabFrmText=ttk.LabelFrame(FrmText,text="帮助",height=800,borderwidth=3)
HelpStr = tk.StringVar()
HelpStr.set(tips)
LabText = ttk.Label(LabFrmText, textvariable=HelpStr,width=55)
LabText.config(wraplength=350)
def on_closing():
global windowflag
windowflag = "close"
print(windowflag)
helpwindow.destroy()
# define button func
def ChgLog():
HelpStr.set(updateThingsString)
def ChgAbout():
HelpStr.set(about)
def ChgCon():
HelpStr.set(contribute)
def ChgTips():
HelpStr.set(tips)
LabText.config(wraplength=350)
BtnReadme = ttk.Button(FrmMenu, text="使用说明",width=14,command=ChgTips)
BtnLog = ttk.Button(FrmMenu, text="更新内容",width=14,command=ChgLog)
BtnGongxian = ttk.Button(FrmMenu, text="有贡献的开发者",width=14,command=ChgCon)
BtnAbout = ttk.Button(FrmMenu, text="关于",width=14,command=ChgAbout)
#layout
FrmMenu.grid(row=0,column=0,sticky=tk.NW)
BtnReadme.grid(row=0,column=0,sticky=tk.NW,padx=3)
BtnLog.grid(row=1,column=0,sticky=tk.NW,padx=3)
BtnGongxian.grid(row=3,column=0,sticky=tk.NW,padx=3)
BtnAbout.grid(row=4,column=0,sticky=tk.NW,padx=3)
FrmText.grid(row=0,column=1,sticky=tk.NW)
LabFrmText.grid(row=0,column=0,sticky=tk.NW,padx=3,pady=3)
LabText.grid(row=0,column=0,sticky=tk.NW)
Frmroot.pack()
windowflag = "open"
print(windowflag)
#helpwindow.mainloop()
helpwindow.protocol("WM_DELETE_WINDOW", on_closing)
###########################
# 窗口创建
###########################
win = tk.Tk() # 创建窗口
# 设置窗口
style = ttkthemes.ThemedStyle(win)
style.set_theme("breeze")
window = ttk.Frame(win)
win.title(title)
win.resizable(0, 0)
win.iconphoto(False, tk.PhotoImage(file=iconPath))
# get screen width and height
screen_width = win.winfo_screenwidth()
screen_height = win.winfo_screenheight()
# calculate position x and y coordinates 假设主窗口大小固定 570x236像素 ,设置窗口位置为屏幕中心。
winwith=570
winhigh=236
x = (screen_width/2) - (winwith/2)
y = (screen_height/2) - (winhigh/2)
win.geometry(""+"+{:.0f}+{:.0f}".format(x, y))
# 创建控件
FrmInstall = ttk.Frame(window)
LabApkPath = ttk.Label(window, text="安装 APK")
ComboInstallPath = ttk.Combobox(window, width=50)
BtnFindApk = ttk.Button(FrmInstall, text="浏览", command=FindApk)
BtnInstall = ttk.Button(FrmInstall, text="安装", command=Button3Install)
BtnShowUengineApp = ttk.Button(window, text="打开程序列表", command=Button5Click)
# 设置菜单栏
menu = tk.Menu(window, background="white")
programmenu = tk.Menu(menu, tearoff=0, background="white") # 设置“程序”菜单栏
help = tk.Menu(menu, tearoff=0, background="white") # 设置“帮助”菜单栏
menu.add_cascade(label="程序", menu=programmenu)
menu.add_cascade(label="关于", menu=help)
programmenu.add_command(label="清空软件历史记录", command=CleanProgramHistory)
programmenu.add_separator() # 设置分界线
programmenu.add_command(label="退出程序", command=window.quit) # 设置“退出程序”
help.add_command(label="程序官网", command=OpenProgramURL) # 设置“程序官网”项
help.add_command(label="反馈程序问题和建议", command=UengineRunnerBugUpload) # 设置“程序官网”项
help.add_command(label="关于", command=showhelp) # 设置“关于这个程序”项
menu.configure(activebackground="dodgerblue")
help.configure(activebackground="dodgerblue")
programmenu.configure(activebackground="dodgerblue")
# 设置控件
#ComboUninstallPath['value'] = fineUninstallApkHistory
ComboInstallPath['value'] = findApkHistory
try:
if sys.argv[1] == "-i":
ComboInstallPath.set(sys.argv[2])
print("Install Path: " + sys.argv[2])
elif sys.argv[1] == "-u":
#ComboUninstallPath.set(sys.argv[2])
ComboInstallPath.set(sys.argv[2])
print("Unstall Path: " + sys.argv[2])
else:
print("Command Format Error")
except:
print("Not Command Or Command Format Error")
# 显示控件
win.config(menu=menu) # 显示菜单栏
LabApkPath.grid(row=0, column=0,sticky= tk.W,padx=3)
ComboInstallPath.grid(row=1, column=0,padx=3)
FrmInstall.grid(row=1, column=1,padx=3, rowspan=1)
BtnFindApk.grid(row=0, column=0)
BtnInstall.grid(row=0, column=1)
BtnShowUengineApp.grid(row=2, column=0,sticky= tk.W,padx=3,pady=2)
window.pack()
win.mainloop()

30
main.py
View File

@ -75,7 +75,6 @@ def ButtonClick8():
threading.Thread(target=UninstallProgram, args=[path]).start()
# 浏览窗口
# temp strs
temppath=""
def FindApk()->"浏览窗口":
path = filedialog.askopenfilename(title="选择 Apk", filetypes=[("APK 文件", "*.apk"), ("所有文件", "*.*")], initialdir=json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApk.json"))["path"])
@ -170,26 +169,6 @@ def Button5Click():
def OpenUengineProgramList()->"打开“uengine 所有程序列表”":
os.system("uengine launch --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity")
# 显示“关于这个程序”窗口
#def about_this_program()->"显示“关于这个程序”窗口":
# global about
# global title
# global iconPath
# mess = tk.Toplevel()
# message = ttk.Frame(mess)
# mess.resizable(0, 0)
# mess.title("关于 {}".format(title))
# #mess.iconphoto(False, tk.PhotoImage(file=iconPath))
# img = ImageTk.PhotoImage(Image.open(iconPath))
# LabApkPath = ttk.Label(message, image=img)
# label2 = ttk.Label(message, text=about)
# button1 = ttk.Button(message, text="确定", command=mess.withdraw)
# LabApkPath.pack()
# label2.pack()
# button1.pack(side="bottom")
# message.pack()
# mess.mainloop()
# 显示“提示”窗口
def helps()->"显示“提示”窗口":
global tips
@ -520,10 +499,6 @@ def SaveInstallUengineApp():
def UengineCheckCpu():
english = GetCommandReturn("uengine check-features")
#chinese = GetCommandReturn("trans -b \"{}\"".format(english)) # 获取中文翻译
#for i in chinese.split("\n"): # 删除提示
# if "Did you mean:" in i:
# chinese = chinese.replace(i, "").replace("\n", "")
messagebox.showinfo(title="提示", message="{}".format(english))
# 获取用户主目录
@ -1270,11 +1245,6 @@ FrmInstall.grid(row=0, column=1,padx=3, rowspan=3)
BtnFindApk.grid(row=0, column=0)
BtnInstall.grid(row=0, column=1)
#LabUninstallPath.grid(row=4, column=0,sticky= tk.W,padx=3)
#ComboUninstallPath.grid(row=5, column=0,padx=3)
#FrmUninstall.grid(row=5, column=1,padx=3)
#BtnUninstallApkBrowser.grid(row=0, column=0)
BtnUninstall.grid(row=1, column=0)
BtnShowUengineApp.grid(row=2, column=0,sticky= tk.W,padx=3,pady=2)

View File

@ -3,7 +3,7 @@ Source: com.gitee.uengine.runner.spark
Version: 1.5.1
Architecture: all
Maintainer: gfdgd xi <3025613752@qq.com>, actionchen<917981399@qq.com>
Depends: deepin-elf-verify (>= 0.0.16.7-1), python3, python3-tk, python3-pip, aapt, uengine, python3-setuptools, deepin-terminal, curl, python3-pil, python3-pil.imagetk, python3-requests, adb, translate-shell
Depends: deepin-elf-verify (>= 0.0.16.7-1), python3, python3-tk, python3-pip, aapt, uengine, python3-setuptools, deepin-terminal, curl, python3-pil, python3-pil.imagetk, python3-requests, adb, translate-shell, python3-xlib
Section: utils
Priority: optional
Conflicts: spark-uengine-runner, spark-uengine-apk-builder

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
#########################################
# 版本1.4.0
# 更新时间2021年08月26日
# 版本1.5.1
# 更新时间2021年10月06日
# Need: unix, python3-tk, python3-pip, pymouse, keyboard
#########################################
import os
@ -57,8 +57,8 @@ def Mouse(key):
print(keybo[key.name]["MousePlace"])
pyautogui.FAILSAFE = False
#os.system(programPath + "/mouse.py {} {}".format(keybo[key.name]["MousePlace"][0], keybo[key.name]["MousePlace"][1]))
#pyautogui.click(keybo[key.name]["MousePlace"][0], keybo[key.name]["MousePlace"][1])
pyautogui.click(1500, 800)
pyautogui.click(keybo[key.name]["MousePlace"][0], keybo[key.name]["MousePlace"][1])
#pyautogui.click(1500, 800)
#m.click(keybo[key.name]["MousePlace"][0],keybo[key.name]["MousePlace"][1])
def Setting(key):

Binary file not shown.

View File

@ -2,8 +2,8 @@
# 使用系统默认的 python3 运行
###########################################################################################
# 作者gfdgd xi
# 版本1.4.2
# 更新时间2021年8月30
# 版本1.5.1
# 更新时间2021年10月06
# 感谢anbox、deepin 和 统信
# 基于 Python3 的 tkinter 构建
###########################################################################################
@ -435,7 +435,7 @@ if len(sys.argv) > 1:
# 设置窗口
style = ttkthemes.ThemedStyle(win)
style.set_theme("breeze")
win.attributes('-alpha', 0.5)
#win.attributes('-alpha', 0.5)
win.title(title)
win.resizable(0, 0)
win.iconphoto(False, tk.PhotoImage(file=iconPath))

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
#########################################
# 版本1.4.0
# 更新时间2021年08月26日
# 版本1.5.1
# 更新时间2021年10月06日
# Need: unix, python3-tk, python3-pip, pymouse, keyboard
#########################################
import os
@ -57,8 +57,8 @@ def Mouse(key):
print(keybo[key.name]["MousePlace"])
pyautogui.FAILSAFE = False
#os.system(programPath + "/mouse.py {} {}".format(keybo[key.name]["MousePlace"][0], keybo[key.name]["MousePlace"][1]))
#pyautogui.click(keybo[key.name]["MousePlace"][0], keybo[key.name]["MousePlace"][1])
pyautogui.click(1500, 800)
pyautogui.click(keybo[key.name]["MousePlace"][0], keybo[key.name]["MousePlace"][1])
#pyautogui.click(1500, 800)
#m.click(keybo[key.name]["MousePlace"][0],keybo[key.name]["MousePlace"][1])
def Setting(key):