Compare commits
112 Commits
1.0.0
...
BashVersio
| Author | SHA1 | Date | |
|---|---|---|---|
| 06b54f9b90 | |||
| 97c4362515 | |||
| 8f6bee1346 | |||
| 00176f9919 | |||
| 8678f122e1 | |||
| ae6c233239 | |||
| 6bf4202cc2 | |||
| 88ca313779 | |||
| 27c39d96a9 | |||
| b34877538a | |||
| eb44817201 | |||
| 7f18273cca | |||
| d3970b8b28 | |||
| 293b382e9b | |||
| c3800a2514 | |||
| 6b42f7eef6 | |||
| a6baf834c7 | |||
| 3f9aa55d8d | |||
| 9660c8fb72 | |||
| acaa13e8ae | |||
| 176025a3c5 | |||
| 8fb872d8ec | |||
| 79674c1c2f | |||
| b7f01d0ff6 | |||
| c030ab2c16 | |||
| 8747f69065 | |||
| b851b12a62 | |||
| da0db9b0fb | |||
| 22d1f1ab87 | |||
| 4a5d060c43 | |||
| d5b37e3951 | |||
| ed2155b83e | |||
| 05d977030c | |||
| c77bbceeb2 | |||
| 7f36a1ff3c | |||
| d68f42c368 | |||
| c9a3db2f37 | |||
| 677ff4c16b | |||
| 65eaf17d85 | |||
| 72cf1e0881 | |||
| c53ad469e5 | |||
| 34e4d83104 | |||
| 5b85af521e | |||
| 158e99c3c4 | |||
| 5e31ca90c5 | |||
| 35fc896aaa | |||
| 9510660321 | |||
| 282bb35444 | |||
| bb813fc866 | |||
| d081862a4a | |||
| 09857468f7 | |||
| 2abc67e426 | |||
| c4ab276ab5 | |||
| 016c397529 | |||
| 4f0fafbf17 | |||
| ad5f08ca38 | |||
| 618a8c4941 | |||
| 9ef3c45ff6 | |||
| ac677c1bb1 | |||
| 655b45de4d | |||
| 278e1722a5 | |||
| 34937827d9 | |||
| 712f2d25cc | |||
| 4845337d73 | |||
| 4fd7840bbe | |||
| 4ec0887a58 | |||
| d105f85510 | |||
| 8057f2a596 | |||
| 74831ea4c2 | |||
| bcaae02aec | |||
| 4b889b6056 | |||
| 76d3710963 | |||
| 89aa00ebf5 | |||
| a2038ac40e | |||
| 530c3ad384 | |||
| c9a1316022 | |||
| f5b04826c2 | |||
| 9d1f3e8176 | |||
| a80397ee9e | |||
| deec28ce83 | |||
| 4dd48b5273 | |||
| a28f4e6ba9 | |||
| 3ba28b053d | |||
| becf3200ec | |||
| db206335b1 | |||
| a1eee38deb | |||
| 67f8d2beca | |||
| d01423853a | |||
| d486fa55d8 | |||
|
|
73d1e3b484 | ||
| ce52b8579a | |||
| fcc37f707e | |||
| 908177b69d | |||
| 89702f681e | |||
| 7786c7b855 | |||
|
|
2c75309d75 | ||
| 38b19ed2d2 | |||
| dcc92846be | |||
| ec8e48aff3 | |||
| 35db9dc361 | |||
| 2da3e3962b | |||
| d749ece476 | |||
| 7beb35d1de | |||
| de71e3b01e | |||
| 0dd7858097 | |||
| 81e2346fc8 | |||
| 1b74fcde2f | |||
| b07d24202e | |||
| 85cf28d552 | |||
| 1c83689a6b | |||
| e6680c9340 | |||
| cd80f32a4b |
0
.idea/.gitignore
generated
vendored
Normal file → Executable file
0
.idea/.gitignore
generated
vendored
Normal file → Executable file
0
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file → Executable file
0
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file → Executable file
2
.idea/misc.xml
generated
Normal file → Executable file
2
.idea/misc.xml
generated
Normal file → Executable file
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7" project-jdk-type="Python SDK" />
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (uengine-runner)" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
0
.idea/modules.xml
generated
Normal file → Executable file
0
.idea/modules.xml
generated
Normal file → Executable file
0
.idea/uengine-install.iml
generated
Normal file → Executable file
0
.idea/uengine-install.iml
generated
Normal file → Executable file
1
.idea/vcs.xml
generated
Normal file → Executable file
1
.idea/vcs.xml
generated
Normal file → Executable file
@@ -2,5 +2,6 @@
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/Internet/random-questions/Question" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
46
README.md
46
README.md
@@ -1,46 +0,0 @@
|
||||
# uengine 运行器
|
||||
|
||||
#### 介绍
|
||||
|
||||
使用 Python3 的 tkinter 构建
|
||||
|
||||
(测试平台:UOS 家庭版)
|
||||
|
||||
(自己美术功底太差,图标直接用 anbox 的了)
|
||||
|
||||
#### 软件架构
|
||||
i386 和 amd64
|
||||
|
||||
|
||||
#### 源码安装教程
|
||||
|
||||
1. 安装所需依赖
|
||||
|
||||
```
|
||||
sudo apt install python3 python3-tk git adb
|
||||
```
|
||||
|
||||
2. 下载本程序
|
||||
|
||||
```
|
||||
git clone https://gitee.com/gfdgd-xi/uengine-runner.git
|
||||
```
|
||||
|
||||
3. 运行本程序
|
||||
|
||||
```
|
||||
cd uengine-runner
|
||||
chmod 777 main.py
|
||||
./main.py
|
||||
```
|
||||
|
||||
|
||||
#### 使用说明
|
||||
|
||||
提示:
|
||||
|
||||
None
|
||||
|
||||
|
||||
#### 特技
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Categories=System;
|
||||
Comment=uengine(anbox) 程序菜单
|
||||
Encoding=UTF-8
|
||||
Exec=/usr/bin/uengine-launch.sh --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity
|
||||
Icon=/opt/apps/uengine-runner/icon.png
|
||||
MimeType=
|
||||
Name=uengine 程序菜单
|
||||
StartupWMClass=uengine 程序菜单
|
||||
Terminal=false
|
||||
Type=Application
|
||||
@@ -1,9 +0,0 @@
|
||||
Package: spark-uengine-runner
|
||||
Version: 1.0.0
|
||||
Maintainer: gfdgd xi <3025613752@qq.com>
|
||||
Homepage: https://gitee.com/gfdgd-xi/uengine-runner
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Depends: python3, python3-tk, adb, python3-pip
|
||||
Description: gfdgd xi make's uengine runner
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
# !/bin/sh
|
||||
sudo pip3 install --upgrade pip
|
||||
sudo pip3 install --upgrade virtualenv
|
||||
pip3 install pillow
|
||||
@@ -1,46 +0,0 @@
|
||||
# uengine 运行器
|
||||
|
||||
#### 介绍
|
||||
|
||||
使用 Python3 的 tkinter 构建
|
||||
|
||||
(测试平台:UOS 家庭版)
|
||||
|
||||
(自己美术功底太差,图标直接用 anbox 的了)
|
||||
|
||||
#### 软件架构
|
||||
i386 和 amd64
|
||||
|
||||
|
||||
#### 源码安装教程
|
||||
|
||||
1. 安装所需依赖
|
||||
|
||||
```
|
||||
sudo apt install python3 python3-tk git adb
|
||||
```
|
||||
|
||||
2. 下载本程序
|
||||
|
||||
```
|
||||
git clone https://gitee.com/gfdgd-xi/uengine-runner.git
|
||||
```
|
||||
|
||||
3. 运行本程序
|
||||
|
||||
```
|
||||
cd uengine-runner
|
||||
chmod 777 main.py
|
||||
./main.py
|
||||
```
|
||||
|
||||
|
||||
#### 使用说明
|
||||
|
||||
提示:
|
||||
|
||||
None
|
||||
|
||||
|
||||
#### 特技
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Categories=System;
|
||||
Comment=uengine(anbox) 程序菜单
|
||||
Encoding=UTF-8
|
||||
Exec=/usr/bin/uengine-launch.sh --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity
|
||||
Icon=/opt/apps/uengine-runner/icon.png
|
||||
MimeType=
|
||||
Name=uengine 程序菜单
|
||||
StartupWMClass=uengine 程序菜单
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB |
@@ -1,299 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# 使用系统默认的 python3 运行
|
||||
###########################################################################################
|
||||
# 作者:gfdgd xi
|
||||
# 版本:1.0.0
|
||||
# 更新时间:2021年
|
||||
# 感谢:
|
||||
# 基于 Python3 的 tkinter 构建
|
||||
###########################################################################################
|
||||
#################
|
||||
# 引入所需的库
|
||||
#################
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import shutil
|
||||
import traceback
|
||||
import threading
|
||||
import webbrowser
|
||||
import subprocess
|
||||
import tkinter as tk
|
||||
import tkinter.ttk as ttk
|
||||
import tkinter.messagebox as messagebox
|
||||
import tkinter.filedialog as filedialog
|
||||
import PIL.Image as Image
|
||||
import PIL.ImageTk as ImageTk
|
||||
|
||||
def KillAdbProgress():
|
||||
DisabledAndEnbled(True)
|
||||
Return = GetCommandReturn("killall adb")
|
||||
if Return is "":
|
||||
Return = "OK!"
|
||||
messagebox.showinfo(title="tips", message=Return)
|
||||
DisabledAndEnbled(False)
|
||||
|
||||
def Button1Click():
|
||||
if combobox2.get() is "":
|
||||
messagebox.showerror(title="Tips", message="Don't input right things in ComboBox")
|
||||
return
|
||||
DisabledAndEnbled(True)
|
||||
threading.Thread(target=ConnectPhoneIp).start()
|
||||
|
||||
def ConnectPhoneIp():
|
||||
global phoneIp
|
||||
messagebox.showinfo(title="tips", message=GetCommandReturn("adb connect '{}'".format(combobox2.get())))
|
||||
phoneIp.append(combobox2.get())
|
||||
combobox2['value'] = phoneIp
|
||||
write_txt(get_home() + "/.config/uengine-runner/PhoneIp.json", str(json.dumps(ListToDictionary(phoneIp)))) # 将历史记录的数组转换为字典并写入
|
||||
DisabledAndEnbled(False)
|
||||
|
||||
def FindApk():
|
||||
path = filedialog.askopenfilename(title="选择 Apk", filetypes=[("APK 文件", "*.apk"), ("所有文件", "*.*")], initialdir=json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApk.json"))["path"])
|
||||
if not path is "":
|
||||
combobox1.set(path)
|
||||
write_txt(get_home() + "/.config/uengine-runner/FindApk.json", json.dumps({"path": os.path.dirname(path)})) # 写入配置文件
|
||||
|
||||
def Button3Install():
|
||||
if combobox1.get() is "":
|
||||
messagebox.showerror(title="Tips", message="Don't input right things in ComboBox")
|
||||
return
|
||||
DisabledAndEnbled(True)
|
||||
threading.Thread(target=InstallApk, args=(combobox1.get(),)).start()
|
||||
|
||||
def InstallApk(path):
|
||||
global findApkHistory
|
||||
messagebox.showinfo(title="Tips", message=GetCommandReturn("adb install '{}'".format(path)))
|
||||
findApkHistory.append(combobox1.get())
|
||||
combobox1['value'] = findApkHistory
|
||||
write_txt(get_home() + "/.config/uengine-runner/FindApkHistory.json", str(json.dumps(ListToDictionary(findApkHistory)))) # 将历史记录的数组转换为字典并写入
|
||||
DisabledAndEnbled(False)
|
||||
|
||||
def DisabledAndEnbled(choose):
|
||||
userChoose = {True: tk.DISABLED, False: tk.NORMAL}
|
||||
a = userChoose[choose]
|
||||
combobox1.configure(state=a)
|
||||
combobox2.configure(state=a)
|
||||
button1.configure(state=a)
|
||||
button2.configure(state=a)
|
||||
button3.configure(state=a)
|
||||
button4.configure(state=a)
|
||||
button5.configure(state=a)
|
||||
|
||||
# 需引入 subprocess
|
||||
def GetCommandReturn(cmd):
|
||||
# cmd 是要获取输出的命令
|
||||
return subprocess.getoutput(cmd)
|
||||
|
||||
def Button5Click():
|
||||
threading.Thread(target=OpenUengineProgramList).start()
|
||||
|
||||
def OpenUengineProgramList():
|
||||
os.system("/usr/bin/uengine-launch.sh --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity")
|
||||
|
||||
# 显示“关于这个程序”窗口
|
||||
def about_this_program():
|
||||
global about
|
||||
global title
|
||||
global iconPath
|
||||
message = tk.Toplevel()
|
||||
message.title("关于 {}".format(title))
|
||||
message.iconphoto(False, tk.PhotoImage(file=iconPath))
|
||||
img = ImageTk.PhotoImage(Image.open(iconPath))
|
||||
label1 = ttk.Label(message, image=img)
|
||||
label2 = ttk.Label(message, text=about)
|
||||
button1 = ttk.Button(message, text="确定", command=message.withdraw)
|
||||
label1.pack()
|
||||
label2.pack()
|
||||
button1.pack(side="bottom")
|
||||
message.mainloop()
|
||||
|
||||
# 显示“提示”窗口
|
||||
def helps():
|
||||
global tips
|
||||
messagebox.showinfo(title="提示", message=tips)
|
||||
|
||||
# 显示更新内容窗口
|
||||
def UpdateThings():
|
||||
messagebox.showinfo(title="更新内容", message=updateThings)
|
||||
|
||||
# 打开程序官网
|
||||
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/uengine-runner")
|
||||
ReStartProgram()
|
||||
except:
|
||||
traceback.print_exc()
|
||||
messagebox.showerror(title="错误", message=traceback.format_exc())
|
||||
|
||||
# 获取用户主目录
|
||||
def get_home():
|
||||
return os.path.expanduser('~')
|
||||
|
||||
def SendUengineAndroidListForDesktop():
|
||||
global desktop
|
||||
global desktopName
|
||||
DisabledAndEnbled(True)
|
||||
try:
|
||||
if os.path.exists("{}/{}".format(get_desktop_path(), desktopName)):
|
||||
if not messagebox.askokcancel(title="提示", message="桌面已经存在快捷方式,你确定要覆盖吗?"):
|
||||
return
|
||||
shutil.copy(desktop, get_desktop_path())
|
||||
messagebox.showinfo(title="提示", message="发送成功!")
|
||||
except:
|
||||
traceback.print_exc()
|
||||
messagebox.showerror(title="错误", message=traceback.format_exc())
|
||||
DisabledAndEnbled(False)
|
||||
|
||||
# 获取用户桌面目录
|
||||
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 SendUengineAndroidListForLauncher():
|
||||
DisabledAndEnbled(True)
|
||||
try:
|
||||
if os.path.exists("{}/.local/share/applications/{}".format(get_home(), desktopName)):
|
||||
if not messagebox.askokcancel(title="提示", message="启动器已经存在快捷方式,你确定要覆盖吗?"):
|
||||
return
|
||||
if not os.path.exists("{}/.local/share/applications/".format(get_home())):
|
||||
os.makedirs("{}/.local/share/applications/".format(get_home()))
|
||||
shutil.copy(desktop, "{}/.local/share/applications/{}".format(get_home(), desktopName))
|
||||
os.system("chmod 755 {}/.local/share/applications/{}".format(get_home(), desktopName))
|
||||
messagebox.showinfo(title="提示", message="发送成功!")
|
||||
except:
|
||||
traceback.print_exc()
|
||||
messagebox.showerror(title="错误", message=traceback.format_exc())
|
||||
DisabledAndEnbled(False)
|
||||
|
||||
# 数组转字典
|
||||
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):
|
||||
file = open(path, 'w', encoding='UTF-8') # 设置文件对象
|
||||
file.write(things) # 写入文本
|
||||
file.close() # 关闭文本对象
|
||||
|
||||
###########################
|
||||
# 程序信息
|
||||
###########################
|
||||
programUrl = "https://gitee.com/gfdgd-xi/uengine-runner"
|
||||
version = "1.0.0"
|
||||
goodRunSystem = "Linux"
|
||||
about = '''一个基于 Python3 的 tkinter 制作的 uengine APK 安装器
|
||||
版本:{}
|
||||
适用平台:{}
|
||||
tkinter 版本:{}
|
||||
程序官网:{}
|
||||
©2021-{} gfdgd xi'''.format(version, goodRunSystem, tk.TkVersion, programUrl, time.strftime("%Y"))
|
||||
tips = '''提示:
|
||||
1、None'''
|
||||
updateThingsString = ''''''
|
||||
title = "uengine 运行器 {}".format(version)
|
||||
updateTime = "2021年"
|
||||
updateThings = "{} 更新内容:\n{}\n更新时间:{}".format(version, updateThingsString, updateTime, time.strftime("%Y"))
|
||||
iconPath = "/opt/apps/uengine-runner/icon.png"
|
||||
desktop = "/opt/apps/uengine-runner/UengineAndroidProgramList.desktop"
|
||||
desktopName = "UengineAndroidProgramList.desktop"
|
||||
|
||||
###########################
|
||||
# 加载配置
|
||||
###########################
|
||||
if not os.path.exists(get_home() + "/.config/uengine-runner"): # 如果没有配置文件夹
|
||||
os.mkdir(get_home() + "/.config/uengine-runner") # 创建配置文件夹
|
||||
if not os.path.exists(get_home() + "/.config/uengine-runner/PhoneIp.json"): # 如果没有配置文件
|
||||
write_txt(get_home() + "/.config/uengine-runner/PhoneIp.json", json.dumps({})) # 创建配置文件
|
||||
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/FindApk.json"): # 如果没有配置文件
|
||||
write_txt(get_home() + "/.config/uengine-runner/FindApk.json", json.dumps({"path": "~"})) # 写入(创建)一个配置文件
|
||||
|
||||
###########################
|
||||
# 设置变量
|
||||
###########################
|
||||
findApkHistory = list(json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkHistory.json")).values())
|
||||
phoneIp = list(json.loads(readtxt(get_home() + "/.config/uengine-runner/PhoneIp.json")).values())
|
||||
|
||||
###########################
|
||||
# 窗口创建
|
||||
###########################
|
||||
window = tk.Tk()
|
||||
window.title(title)
|
||||
window.iconphoto(False, tk.PhotoImage(file=iconPath))
|
||||
frame1 = ttk.Frame(window)
|
||||
frame2 = ttk.Frame(window)
|
||||
label1 = ttk.Label(window, text="要安装的 apk 路径:")
|
||||
label2 = ttk.Label(window, text="要连接的设备的 IP(默认 IP 为 192.168.250.2):")
|
||||
combobox1 = ttk.Combobox(window, width=100)
|
||||
combobox2 = ttk.Combobox(window, width=100)
|
||||
button1 = ttk.Button(frame1, text="连接设备", command=ConnectPhoneIp)
|
||||
button2 = ttk.Button(window, text="浏览", command=FindApk)
|
||||
button3 = ttk.Button(frame2, text="安装", command=Button3Install)
|
||||
button4 = ttk.Button(frame1, text="Kill Adb Progress", command=KillAdbProgress)
|
||||
button5 = ttk.Button(frame2, text="Open uengine Program List", command=Button5Click)
|
||||
menu = tk.Menu(window) # 设置菜单栏
|
||||
programmenu = tk.Menu(menu, tearoff=0) # 设置“程序”菜单栏
|
||||
menu.add_cascade(label="程序", menu=programmenu)
|
||||
programmenu.add_command(label="清空软件历史记录", command=CleanProgramHistory)
|
||||
programmenu.add_separator() # 设置分界线
|
||||
programmenu.add_command(label="退出程序", command=window.quit) # 设置“退出程序”项
|
||||
uengine = tk.Menu(menu, tearoff=0)
|
||||
menu.add_cascade(label="uengine", menu=uengine)
|
||||
uengine.add_command(label="发送 uengine 应用列表到桌面", command=SendUengineAndroidListForDesktop)
|
||||
uengine.add_command(label="发送 uengine 应用列表到启动器", command=SendUengineAndroidListForLauncher)
|
||||
help = tk.Menu(menu, tearoff=0) # 设置“帮助”菜单栏
|
||||
menu.add_cascade(label="帮助", menu=help)
|
||||
help.add_command(label="程序官网", command=OpenProgramURL) # 设置“程序官网”项
|
||||
help.add_separator()
|
||||
help.add_command(label="小提示", command=helps) # 设置“小提示”项
|
||||
help.add_command(label="更新内容", command=UpdateThings) # 设置“更新内容”项
|
||||
help.add_command(label="关于这个程序", command=about_this_program) # 设置“关于这个程序”项
|
||||
# 设置控件
|
||||
combobox2['value'] = phoneIp
|
||||
combobox1['value'] = findApkHistory
|
||||
#
|
||||
window.config(menu=menu) # 显示菜单栏
|
||||
label1.grid(row=2, column=0)
|
||||
label2.grid(row=0, column=0)
|
||||
combobox1.grid(row=2, column=1)
|
||||
combobox2.grid(row=0, column=1)
|
||||
button1.grid(column=0, row=0)
|
||||
button2.grid(row=2, column=2)
|
||||
button3.grid(row=0, column=0)
|
||||
button4.grid(column=1, row=0)
|
||||
button5.grid(row=0, column=1)
|
||||
frame1.grid(row=1, columnspa=3)
|
||||
frame2.grid(row=3, columnspa=3)
|
||||
window.mainloop()
|
||||
@@ -1,299 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# 使用系统默认的 python3 运行
|
||||
###########################################################################################
|
||||
# 作者:gfdgd xi
|
||||
# 版本:1.0.0
|
||||
# 更新时间:2021年
|
||||
# 感谢:
|
||||
# 基于 Python3 的 tkinter 构建
|
||||
###########################################################################################
|
||||
#################
|
||||
# 引入所需的库
|
||||
#################
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import shutil
|
||||
import traceback
|
||||
import threading
|
||||
import webbrowser
|
||||
import subprocess
|
||||
import tkinter as tk
|
||||
import tkinter.ttk as ttk
|
||||
import tkinter.messagebox as messagebox
|
||||
import tkinter.filedialog as filedialog
|
||||
import PIL.Image as Image
|
||||
import PIL.ImageTk as ImageTk
|
||||
|
||||
def KillAdbProgress():
|
||||
DisabledAndEnbled(True)
|
||||
Return = GetCommandReturn("killall adb")
|
||||
if Return is "":
|
||||
Return = "OK!"
|
||||
messagebox.showinfo(title="tips", message=Return)
|
||||
DisabledAndEnbled(False)
|
||||
|
||||
def Button1Click():
|
||||
if combobox2.get() is "":
|
||||
messagebox.showerror(title="Tips", message="Don't input right things in ComboBox")
|
||||
return
|
||||
DisabledAndEnbled(True)
|
||||
threading.Thread(target=ConnectPhoneIp).start()
|
||||
|
||||
def ConnectPhoneIp():
|
||||
global phoneIp
|
||||
messagebox.showinfo(title="tips", message=GetCommandReturn("adb connect '{}'".format(combobox2.get())))
|
||||
phoneIp.append(combobox2.get())
|
||||
combobox2['value'] = phoneIp
|
||||
write_txt(get_home() + "/.config/uengine-runner/PhoneIp.json", str(json.dumps(ListToDictionary(phoneIp)))) # 将历史记录的数组转换为字典并写入
|
||||
DisabledAndEnbled(False)
|
||||
|
||||
def FindApk():
|
||||
path = filedialog.askopenfilename(title="选择 Apk", filetypes=[("APK 文件", "*.apk"), ("所有文件", "*.*")], initialdir=json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApk.json"))["path"])
|
||||
if not path is "":
|
||||
combobox1.set(path)
|
||||
write_txt(get_home() + "/.config/uengine-runner/FindApk.json", json.dumps({"path": os.path.dirname(path)})) # 写入配置文件
|
||||
|
||||
def Button3Install():
|
||||
if combobox1.get() is "":
|
||||
messagebox.showerror(title="Tips", message="Don't input right things in ComboBox")
|
||||
return
|
||||
DisabledAndEnbled(True)
|
||||
threading.Thread(target=InstallApk, args=(combobox1.get(),)).start()
|
||||
|
||||
def InstallApk(path):
|
||||
global findApkHistory
|
||||
messagebox.showinfo(title="Tips", message=GetCommandReturn("adb install '{}'".format(path)))
|
||||
findApkHistory.append(combobox1.get())
|
||||
combobox1['value'] = findApkHistory
|
||||
write_txt(get_home() + "/.config/uengine-runner/FindApkHistory.json", str(json.dumps(ListToDictionary(findApkHistory)))) # 将历史记录的数组转换为字典并写入
|
||||
DisabledAndEnbled(False)
|
||||
|
||||
def DisabledAndEnbled(choose):
|
||||
userChoose = {True: tk.DISABLED, False: tk.NORMAL}
|
||||
a = userChoose[choose]
|
||||
combobox1.configure(state=a)
|
||||
combobox2.configure(state=a)
|
||||
button1.configure(state=a)
|
||||
button2.configure(state=a)
|
||||
button3.configure(state=a)
|
||||
button4.configure(state=a)
|
||||
button5.configure(state=a)
|
||||
|
||||
# 需引入 subprocess
|
||||
def GetCommandReturn(cmd):
|
||||
# cmd 是要获取输出的命令
|
||||
return subprocess.getoutput(cmd)
|
||||
|
||||
def Button5Click():
|
||||
threading.Thread(target=OpenUengineProgramList).start()
|
||||
|
||||
def OpenUengineProgramList():
|
||||
os.system("/usr/bin/uengine-launch.sh --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity")
|
||||
|
||||
# 显示“关于这个程序”窗口
|
||||
def about_this_program():
|
||||
global about
|
||||
global title
|
||||
global iconPath
|
||||
message = tk.Toplevel()
|
||||
message.title("关于 {}".format(title))
|
||||
message.iconphoto(False, tk.PhotoImage(file=iconPath))
|
||||
img = ImageTk.PhotoImage(Image.open(iconPath))
|
||||
label1 = ttk.Label(message, image=img)
|
||||
label2 = ttk.Label(message, text=about)
|
||||
button1 = ttk.Button(message, text="确定", command=message.withdraw)
|
||||
label1.pack()
|
||||
label2.pack()
|
||||
button1.pack(side="bottom")
|
||||
message.mainloop()
|
||||
|
||||
# 显示“提示”窗口
|
||||
def helps():
|
||||
global tips
|
||||
messagebox.showinfo(title="提示", message=tips)
|
||||
|
||||
# 显示更新内容窗口
|
||||
def UpdateThings():
|
||||
messagebox.showinfo(title="更新内容", message=updateThings)
|
||||
|
||||
# 打开程序官网
|
||||
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/uengine-runner")
|
||||
ReStartProgram()
|
||||
except:
|
||||
traceback.print_exc()
|
||||
messagebox.showerror(title="错误", message=traceback.format_exc())
|
||||
|
||||
# 获取用户主目录
|
||||
def get_home():
|
||||
return os.path.expanduser('~')
|
||||
|
||||
def SendUengineAndroidListForDesktop():
|
||||
global desktop
|
||||
global desktopName
|
||||
DisabledAndEnbled(True)
|
||||
try:
|
||||
if os.path.exists("{}/{}".format(get_desktop_path(), desktopName)):
|
||||
if not messagebox.askokcancel(title="提示", message="桌面已经存在快捷方式,你确定要覆盖吗?"):
|
||||
return
|
||||
shutil.copy(desktop, get_desktop_path())
|
||||
messagebox.showinfo(title="提示", message="发送成功!")
|
||||
except:
|
||||
traceback.print_exc()
|
||||
messagebox.showerror(title="错误", message=traceback.format_exc())
|
||||
DisabledAndEnbled(False)
|
||||
|
||||
# 获取用户桌面目录
|
||||
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 SendUengineAndroidListForLauncher():
|
||||
DisabledAndEnbled(True)
|
||||
try:
|
||||
if os.path.exists("{}/.local/share/applications/{}".format(get_home(), desktopName)):
|
||||
if not messagebox.askokcancel(title="提示", message="启动器已经存在快捷方式,你确定要覆盖吗?"):
|
||||
return
|
||||
if not os.path.exists("{}/.local/share/applications/".format(get_home())):
|
||||
os.makedirs("{}/.local/share/applications/".format(get_home()))
|
||||
shutil.copy(desktop, "{}/.local/share/applications/{}".format(get_home(), desktopName))
|
||||
os.system("chmod 755 {}/.local/share/applications/{}".format(get_home(), desktopName))
|
||||
messagebox.showinfo(title="提示", message="发送成功!")
|
||||
except:
|
||||
traceback.print_exc()
|
||||
messagebox.showerror(title="错误", message=traceback.format_exc())
|
||||
DisabledAndEnbled(False)
|
||||
|
||||
# 数组转字典
|
||||
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):
|
||||
file = open(path, 'w', encoding='UTF-8') # 设置文件对象
|
||||
file.write(things) # 写入文本
|
||||
file.close() # 关闭文本对象
|
||||
|
||||
###########################
|
||||
# 程序信息
|
||||
###########################
|
||||
programUrl = "https://gitee.com/gfdgd-xi/uengine-runner"
|
||||
version = "1.0.0"
|
||||
goodRunSystem = "Linux"
|
||||
about = '''一个基于 Python3 的 tkinter 制作的 uengine APK 安装器
|
||||
版本:{}
|
||||
适用平台:{}
|
||||
tkinter 版本:{}
|
||||
程序官网:{}
|
||||
©2021-{} gfdgd xi'''.format(version, goodRunSystem, tk.TkVersion, programUrl, time.strftime("%Y"))
|
||||
tips = '''提示:
|
||||
1、None'''
|
||||
updateThingsString = ''''''
|
||||
title = "uengine 运行器 {}".format(version)
|
||||
updateTime = "2021年"
|
||||
updateThings = "{} 更新内容:\n{}\n更新时间:{}".format(version, updateThingsString, updateTime, time.strftime("%Y"))
|
||||
iconPath = "/opt/apps/uengine-runner/icon.png"
|
||||
desktop = "/opt/apps/uengine-runner/UengineAndroidProgramList.desktop"
|
||||
desktopName = "UengineAndroidProgramList.desktop"
|
||||
|
||||
###########################
|
||||
# 加载配置
|
||||
###########################
|
||||
if not os.path.exists(get_home() + "/.config/uengine-runner"): # 如果没有配置文件夹
|
||||
os.mkdir(get_home() + "/.config/uengine-runner") # 创建配置文件夹
|
||||
if not os.path.exists(get_home() + "/.config/uengine-runner/PhoneIp.json"): # 如果没有配置文件
|
||||
write_txt(get_home() + "/.config/uengine-runner/PhoneIp.json", json.dumps({})) # 创建配置文件
|
||||
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/FindApk.json"): # 如果没有配置文件
|
||||
write_txt(get_home() + "/.config/uengine-runner/FindApk.json", json.dumps({"path": "~"})) # 写入(创建)一个配置文件
|
||||
|
||||
###########################
|
||||
# 设置变量
|
||||
###########################
|
||||
findApkHistory = list(json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkHistory.json")).values())
|
||||
phoneIp = list(json.loads(readtxt(get_home() + "/.config/uengine-runner/PhoneIp.json")).values())
|
||||
|
||||
###########################
|
||||
# 窗口创建
|
||||
###########################
|
||||
window = tk.Tk()
|
||||
window.title(title)
|
||||
window.iconphoto(False, tk.PhotoImage(file=iconPath))
|
||||
frame1 = ttk.Frame(window)
|
||||
frame2 = ttk.Frame(window)
|
||||
label1 = ttk.Label(window, text="要安装的 apk 路径:")
|
||||
label2 = ttk.Label(window, text="要连接的设备的 IP(默认 IP 为 192.168.250.2):")
|
||||
combobox1 = ttk.Combobox(window, width=100)
|
||||
combobox2 = ttk.Combobox(window, width=100)
|
||||
button1 = ttk.Button(frame1, text="连接设备", command=ConnectPhoneIp)
|
||||
button2 = ttk.Button(window, text="浏览", command=FindApk)
|
||||
button3 = ttk.Button(frame2, text="安装", command=Button3Install)
|
||||
button4 = ttk.Button(frame1, text="Kill Adb Progress", command=KillAdbProgress)
|
||||
button5 = ttk.Button(frame2, text="Open uengine Program List", command=Button5Click)
|
||||
menu = tk.Menu(window) # 设置菜单栏
|
||||
programmenu = tk.Menu(menu, tearoff=0) # 设置“程序”菜单栏
|
||||
menu.add_cascade(label="程序", menu=programmenu)
|
||||
programmenu.add_command(label="清空软件历史记录", command=CleanProgramHistory)
|
||||
programmenu.add_separator() # 设置分界线
|
||||
programmenu.add_command(label="退出程序", command=window.quit) # 设置“退出程序”项
|
||||
uengine = tk.Menu(menu, tearoff=0)
|
||||
menu.add_cascade(label="uengine", menu=uengine)
|
||||
uengine.add_command(label="发送 uengine 应用列表到桌面", command=SendUengineAndroidListForDesktop)
|
||||
uengine.add_command(label="发送 uengine 应用列表到启动器", command=SendUengineAndroidListForLauncher)
|
||||
help = tk.Menu(menu, tearoff=0) # 设置“帮助”菜单栏
|
||||
menu.add_cascade(label="帮助", menu=help)
|
||||
help.add_command(label="程序官网", command=OpenProgramURL) # 设置“程序官网”项
|
||||
help.add_separator()
|
||||
help.add_command(label="小提示", command=helps) # 设置“小提示”项
|
||||
help.add_command(label="更新内容", command=UpdateThings) # 设置“更新内容”项
|
||||
help.add_command(label="关于这个程序", command=about_this_program) # 设置“关于这个程序”项
|
||||
# 设置控件
|
||||
combobox2['value'] = phoneIp
|
||||
combobox1['value'] = findApkHistory
|
||||
#
|
||||
window.config(menu=menu) # 显示菜单栏
|
||||
label1.grid(row=2, column=0)
|
||||
label2.grid(row=0, column=0)
|
||||
combobox1.grid(row=2, column=1)
|
||||
combobox2.grid(row=0, column=1)
|
||||
button1.grid(column=0, row=0)
|
||||
button2.grid(row=2, column=2)
|
||||
button3.grid(row=0, column=0)
|
||||
button4.grid(column=1, row=0)
|
||||
button5.grid(row=0, column=1)
|
||||
frame1.grid(row=1, columnspa=3)
|
||||
frame2.grid(row=3, columnspa=3)
|
||||
window.mainloop()
|
||||
@@ -1,11 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Categories=System;
|
||||
Comment=uengine(anbox) 运行器
|
||||
Encoding=UTF-8
|
||||
Exec=/usr/bin/uengine-runner
|
||||
Icon=/opt/apps/uengine-runner/icon.png
|
||||
MimeType=
|
||||
Name=uengine 运行器
|
||||
StartupWMClass=uengine 运行器
|
||||
Terminal=false
|
||||
Type=Application
|
||||
11
main.py
11
main.py
@@ -1,11 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Categories=System;
|
||||
Comment=uengine(anbox) 程序菜单
|
||||
Encoding=UTF-8
|
||||
Exec=/usr/bin/uengine-launch.sh --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity
|
||||
Icon=/opt/apps/uengine-runner/icon.png
|
||||
MimeType=
|
||||
Name=uengine 程序菜单
|
||||
StartupWMClass=uengine 程序菜单
|
||||
Terminal=false
|
||||
Type=Application
|
||||
26
main.sh
Normal file
26
main.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
#########################################################################
|
||||
# 作者:gfdgd xi、为什么您不喜欢熊出没和阿布
|
||||
# 版本:1.8.1
|
||||
#########################################################################
|
||||
#################
|
||||
# 引入所需的库
|
||||
#################
|
||||
echo 'mmmmm '
|
||||
echo '# "# m m m mm m mm mmm m mm '
|
||||
echo '#mmmm" # # #" # #" # #" # #" "'
|
||||
echo '# "m # # # # # # #"""" # '
|
||||
echo '# " "mm"# # # # # "#mm" # '
|
||||
echo
|
||||
echo
|
||||
while [ true ]
|
||||
do
|
||||
echo "请输入 APK 路径或将 APK 文件拖入此处"
|
||||
read path
|
||||
if [ ! -d $path ]; then
|
||||
echo APK路径不存在,请重新输入
|
||||
echo
|
||||
continue
|
||||
fi
|
||||
uengine install --apk='$path'
|
||||
done
|
||||
Binary file not shown.
299
uengine-runner
299
uengine-runner
@@ -1,299 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# 使用系统默认的 python3 运行
|
||||
###########################################################################################
|
||||
# 作者:gfdgd xi
|
||||
# 版本:1.0.0
|
||||
# 更新时间:2021年
|
||||
# 感谢:
|
||||
# 基于 Python3 的 tkinter 构建
|
||||
###########################################################################################
|
||||
#################
|
||||
# 引入所需的库
|
||||
#################
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import shutil
|
||||
import traceback
|
||||
import threading
|
||||
import webbrowser
|
||||
import subprocess
|
||||
import tkinter as tk
|
||||
import tkinter.ttk as ttk
|
||||
import tkinter.messagebox as messagebox
|
||||
import tkinter.filedialog as filedialog
|
||||
import PIL.Image as Image
|
||||
import PIL.ImageTk as ImageTk
|
||||
|
||||
def KillAdbProgress():
|
||||
DisabledAndEnbled(True)
|
||||
Return = GetCommandReturn("killall adb")
|
||||
if Return is "":
|
||||
Return = "OK!"
|
||||
messagebox.showinfo(title="tips", message=Return)
|
||||
DisabledAndEnbled(False)
|
||||
|
||||
def Button1Click():
|
||||
if combobox2.get() is "":
|
||||
messagebox.showerror(title="Tips", message="Don't input right things in ComboBox")
|
||||
return
|
||||
DisabledAndEnbled(True)
|
||||
threading.Thread(target=ConnectPhoneIp).start()
|
||||
|
||||
def ConnectPhoneIp():
|
||||
global phoneIp
|
||||
messagebox.showinfo(title="tips", message=GetCommandReturn("adb connect '{}'".format(combobox2.get())))
|
||||
phoneIp.append(combobox2.get())
|
||||
combobox2['value'] = phoneIp
|
||||
write_txt(get_home() + "/.config/uengine-runner/PhoneIp.json", str(json.dumps(ListToDictionary(phoneIp)))) # 将历史记录的数组转换为字典并写入
|
||||
DisabledAndEnbled(False)
|
||||
|
||||
def FindApk():
|
||||
path = filedialog.askopenfilename(title="选择 Apk", filetypes=[("APK 文件", "*.apk"), ("所有文件", "*.*")], initialdir=json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApk.json"))["path"])
|
||||
if not path is "":
|
||||
combobox1.set(path)
|
||||
write_txt(get_home() + "/.config/uengine-runner/FindApk.json", json.dumps({"path": os.path.dirname(path)})) # 写入配置文件
|
||||
|
||||
def Button3Install():
|
||||
if combobox1.get() is "":
|
||||
messagebox.showerror(title="Tips", message="Don't input right things in ComboBox")
|
||||
return
|
||||
DisabledAndEnbled(True)
|
||||
threading.Thread(target=InstallApk, args=(combobox1.get(),)).start()
|
||||
|
||||
def InstallApk(path):
|
||||
global findApkHistory
|
||||
messagebox.showinfo(title="Tips", message=GetCommandReturn("adb install '{}'".format(path)))
|
||||
findApkHistory.append(combobox1.get())
|
||||
combobox1['value'] = findApkHistory
|
||||
write_txt(get_home() + "/.config/uengine-runner/FindApkHistory.json", str(json.dumps(ListToDictionary(findApkHistory)))) # 将历史记录的数组转换为字典并写入
|
||||
DisabledAndEnbled(False)
|
||||
|
||||
def DisabledAndEnbled(choose):
|
||||
userChoose = {True: tk.DISABLED, False: tk.NORMAL}
|
||||
a = userChoose[choose]
|
||||
combobox1.configure(state=a)
|
||||
combobox2.configure(state=a)
|
||||
button1.configure(state=a)
|
||||
button2.configure(state=a)
|
||||
button3.configure(state=a)
|
||||
button4.configure(state=a)
|
||||
button5.configure(state=a)
|
||||
|
||||
# 需引入 subprocess
|
||||
def GetCommandReturn(cmd):
|
||||
# cmd 是要获取输出的命令
|
||||
return subprocess.getoutput(cmd)
|
||||
|
||||
def Button5Click():
|
||||
threading.Thread(target=OpenUengineProgramList).start()
|
||||
|
||||
def OpenUengineProgramList():
|
||||
os.system("/usr/bin/uengine-launch.sh --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity")
|
||||
|
||||
# 显示“关于这个程序”窗口
|
||||
def about_this_program():
|
||||
global about
|
||||
global title
|
||||
global iconPath
|
||||
message = tk.Toplevel()
|
||||
message.title("关于 {}".format(title))
|
||||
message.iconphoto(False, tk.PhotoImage(file=iconPath))
|
||||
img = ImageTk.PhotoImage(Image.open(iconPath))
|
||||
label1 = ttk.Label(message, image=img)
|
||||
label2 = ttk.Label(message, text=about)
|
||||
button1 = ttk.Button(message, text="确定", command=message.withdraw)
|
||||
label1.pack()
|
||||
label2.pack()
|
||||
button1.pack(side="bottom")
|
||||
message.mainloop()
|
||||
|
||||
# 显示“提示”窗口
|
||||
def helps():
|
||||
global tips
|
||||
messagebox.showinfo(title="提示", message=tips)
|
||||
|
||||
# 显示更新内容窗口
|
||||
def UpdateThings():
|
||||
messagebox.showinfo(title="更新内容", message=updateThings)
|
||||
|
||||
# 打开程序官网
|
||||
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/uengine-runner")
|
||||
ReStartProgram()
|
||||
except:
|
||||
traceback.print_exc()
|
||||
messagebox.showerror(title="错误", message=traceback.format_exc())
|
||||
|
||||
# 获取用户主目录
|
||||
def get_home():
|
||||
return os.path.expanduser('~')
|
||||
|
||||
def SendUengineAndroidListForDesktop():
|
||||
global desktop
|
||||
global desktopName
|
||||
DisabledAndEnbled(True)
|
||||
try:
|
||||
if os.path.exists("{}/{}".format(get_desktop_path(), desktopName)):
|
||||
if not messagebox.askokcancel(title="提示", message="桌面已经存在快捷方式,你确定要覆盖吗?"):
|
||||
return
|
||||
shutil.copy(desktop, get_desktop_path())
|
||||
messagebox.showinfo(title="提示", message="发送成功!")
|
||||
except:
|
||||
traceback.print_exc()
|
||||
messagebox.showerror(title="错误", message=traceback.format_exc())
|
||||
DisabledAndEnbled(False)
|
||||
|
||||
# 获取用户桌面目录
|
||||
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 SendUengineAndroidListForLauncher():
|
||||
DisabledAndEnbled(True)
|
||||
try:
|
||||
if os.path.exists("{}/.local/share/applications/{}".format(get_home(), desktopName)):
|
||||
if not messagebox.askokcancel(title="提示", message="启动器已经存在快捷方式,你确定要覆盖吗?"):
|
||||
return
|
||||
if not os.path.exists("{}/.local/share/applications/".format(get_home())):
|
||||
os.makedirs("{}/.local/share/applications/".format(get_home()))
|
||||
shutil.copy(desktop, "{}/.local/share/applications/{}".format(get_home(), desktopName))
|
||||
os.system("chmod 755 {}/.local/share/applications/{}".format(get_home(), desktopName))
|
||||
messagebox.showinfo(title="提示", message="发送成功!")
|
||||
except:
|
||||
traceback.print_exc()
|
||||
messagebox.showerror(title="错误", message=traceback.format_exc())
|
||||
DisabledAndEnbled(False)
|
||||
|
||||
# 数组转字典
|
||||
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):
|
||||
file = open(path, 'w', encoding='UTF-8') # 设置文件对象
|
||||
file.write(things) # 写入文本
|
||||
file.close() # 关闭文本对象
|
||||
|
||||
###########################
|
||||
# 程序信息
|
||||
###########################
|
||||
programUrl = "https://gitee.com/gfdgd-xi/uengine-runner"
|
||||
version = "1.0.0"
|
||||
goodRunSystem = "Linux"
|
||||
about = '''一个基于 Python3 的 tkinter 制作的 uengine APK 安装器
|
||||
版本:{}
|
||||
适用平台:{}
|
||||
tkinter 版本:{}
|
||||
程序官网:{}
|
||||
©2021-{} gfdgd xi'''.format(version, goodRunSystem, tk.TkVersion, programUrl, time.strftime("%Y"))
|
||||
tips = '''提示:
|
||||
1、None'''
|
||||
updateThingsString = ''''''
|
||||
title = "uengine 运行器 {}".format(version)
|
||||
updateTime = "2021年"
|
||||
updateThings = "{} 更新内容:\n{}\n更新时间:{}".format(version, updateThingsString, updateTime, time.strftime("%Y"))
|
||||
iconPath = "/opt/apps/uengine-runner/icon.png"
|
||||
desktop = "/opt/apps/uengine-runner/UengineAndroidProgramList.desktop"
|
||||
desktopName = "UengineAndroidProgramList.desktop"
|
||||
|
||||
###########################
|
||||
# 加载配置
|
||||
###########################
|
||||
if not os.path.exists(get_home() + "/.config/uengine-runner"): # 如果没有配置文件夹
|
||||
os.mkdir(get_home() + "/.config/uengine-runner") # 创建配置文件夹
|
||||
if not os.path.exists(get_home() + "/.config/uengine-runner/PhoneIp.json"): # 如果没有配置文件
|
||||
write_txt(get_home() + "/.config/uengine-runner/PhoneIp.json", json.dumps({})) # 创建配置文件
|
||||
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/FindApk.json"): # 如果没有配置文件
|
||||
write_txt(get_home() + "/.config/uengine-runner/FindApk.json", json.dumps({"path": "~"})) # 写入(创建)一个配置文件
|
||||
|
||||
###########################
|
||||
# 设置变量
|
||||
###########################
|
||||
findApkHistory = list(json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkHistory.json")).values())
|
||||
phoneIp = list(json.loads(readtxt(get_home() + "/.config/uengine-runner/PhoneIp.json")).values())
|
||||
|
||||
###########################
|
||||
# 窗口创建
|
||||
###########################
|
||||
window = tk.Tk()
|
||||
window.title(title)
|
||||
window.iconphoto(False, tk.PhotoImage(file=iconPath))
|
||||
frame1 = ttk.Frame(window)
|
||||
frame2 = ttk.Frame(window)
|
||||
label1 = ttk.Label(window, text="要安装的 apk 路径:")
|
||||
label2 = ttk.Label(window, text="要连接的设备的 IP(默认 IP 为 192.168.250.2):")
|
||||
combobox1 = ttk.Combobox(window, width=100)
|
||||
combobox2 = ttk.Combobox(window, width=100)
|
||||
button1 = ttk.Button(frame1, text="连接设备", command=ConnectPhoneIp)
|
||||
button2 = ttk.Button(window, text="浏览", command=FindApk)
|
||||
button3 = ttk.Button(frame2, text="安装", command=Button3Install)
|
||||
button4 = ttk.Button(frame1, text="Kill Adb Progress", command=KillAdbProgress)
|
||||
button5 = ttk.Button(frame2, text="Open uengine Program List", command=Button5Click)
|
||||
menu = tk.Menu(window) # 设置菜单栏
|
||||
programmenu = tk.Menu(menu, tearoff=0) # 设置“程序”菜单栏
|
||||
menu.add_cascade(label="程序", menu=programmenu)
|
||||
programmenu.add_command(label="清空软件历史记录", command=CleanProgramHistory)
|
||||
programmenu.add_separator() # 设置分界线
|
||||
programmenu.add_command(label="退出程序", command=window.quit) # 设置“退出程序”项
|
||||
uengine = tk.Menu(menu, tearoff=0)
|
||||
menu.add_cascade(label="uengine", menu=uengine)
|
||||
uengine.add_command(label="发送 uengine 应用列表到桌面", command=SendUengineAndroidListForDesktop)
|
||||
uengine.add_command(label="发送 uengine 应用列表到启动器", command=SendUengineAndroidListForLauncher)
|
||||
help = tk.Menu(menu, tearoff=0) # 设置“帮助”菜单栏
|
||||
menu.add_cascade(label="帮助", menu=help)
|
||||
help.add_command(label="程序官网", command=OpenProgramURL) # 设置“程序官网”项
|
||||
help.add_separator()
|
||||
help.add_command(label="小提示", command=helps) # 设置“小提示”项
|
||||
help.add_command(label="更新内容", command=UpdateThings) # 设置“更新内容”项
|
||||
help.add_command(label="关于这个程序", command=about_this_program) # 设置“关于这个程序”项
|
||||
# 设置控件
|
||||
combobox2['value'] = phoneIp
|
||||
combobox1['value'] = findApkHistory
|
||||
#
|
||||
window.config(menu=menu) # 显示菜单栏
|
||||
label1.grid(row=2, column=0)
|
||||
label2.grid(row=0, column=0)
|
||||
combobox1.grid(row=2, column=1)
|
||||
combobox2.grid(row=0, column=1)
|
||||
button1.grid(column=0, row=0)
|
||||
button2.grid(row=2, column=2)
|
||||
button3.grid(row=0, column=0)
|
||||
button4.grid(column=1, row=0)
|
||||
button5.grid(row=0, column=1)
|
||||
frame1.grid(row=1, columnspa=3)
|
||||
frame2.grid(row=3, columnspa=3)
|
||||
window.mainloop()
|
||||
Reference in New Issue
Block a user