1.4.0(1.3.3没了)

This commit is contained in:
gfdgd xi 2021-08-19 14:08:05 +08:00
parent f5b04826c2
commit c9a1316022
39 changed files with 3034 additions and 418 deletions

View File

@ -7,6 +7,15 @@
(自己美术功底太差,图标直接用 anbox 的了)
### 更新内容
#### V1.4.0
**※1、添加新版打包方式deepin打包方式;**
**※2、支持测试运行/创建/删除uengine图标;**
**※3、支持提取安装的apk;**
**※4、支持打包deb包;**
5、修改菜单栏布局;
6、支持打开uengine数据目录和用户数据目录;
7、程序信息保存到json,非直接写入程序本体;
8、更多命令操作;
#### V1.3.2
**※1、支持uengine数据重置;**

View File

@ -1,10 +1,10 @@
Package: spark-uengine-runner
Version: 1.3.2
Version: 1.4.0
Maintainer: gfdgd xi <3025613752@qq.com>, actionchen<917981399@qq.com>
Homepage: [https://gitee.com/gfdgd-xi/uengine-runner, https://github.com/gfdgd-xi/uengine-runner]
Architecture: all
Priority: optional
Conflicts: com.gitee.uengine.runner.spark
Conflicts: com.gitee.uengine.runner.spark, spark-uengine-apk-builder
Depends: python3, python3-tk, python3-pip, aapt, uengine, python3-pil, python3-setuptools
Description: uengine runner for deepin and UOS

View File

@ -0,0 +1,373 @@
Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter
the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination
--------------
5.1. The rights granted under this License will terminate automatically
if You fail to comply with any of its terms. However, if You become
compliant, then the rights granted under this License from a particular
Contributor are reinstated (a) provisionally, unless and until such
Contributor explicitly and finally terminates Your grants, and (b) on an
ongoing basis, if such Contributor fails to notify You of the
non-compliance by some reasonable means prior to 60 days after You have
come back into compliance. Moreover, Your grants from a particular
Contributor are reinstated on an ongoing basis if such Contributor
notifies You of the non-compliance by some reasonable means, this is the
first time You have received notice of non-compliance with this License
from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
************************************************************************
* *
* 7. Limitation of Liability *
* -------------------------- *
* *
* Under no circumstances and under no legal theory, whether tort *
* (including negligence), contract, or otherwise, shall any *
* Contributor, or anyone who distributes Covered Software as *
* permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
8. Litigation
-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
Nothing in this Section shall prevent a party's ability to bring
cross-claims or counter-claims.
9. Miscellaneous
----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
10. Versions of the License
---------------------------
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.

5
build/opt/apps/uengine-runner/getxmlimg.py Executable file → Normal file
View File

@ -50,13 +50,16 @@ class getsavexml():
#获取所有带前后图片ID的图片路径相同背景或者前景的图片ID但分辨率不一样
backimgs = Findpicpath(resourcelines,backimgid)
foreimgs = Findpicpath(resourcelines,foreimgid)
print(backimgs)
print(foreimgs)
#获取分辨率最高的图片路径
def getmaxsize(imgs):
j = 0
size=(0,0)
zipapk = zipfile.ZipFile(apkFilePath)
imgpath = ""
while j < len(imgs):
print(imgs[j])
img = Image.open(zipapk.open(imgs[j]))
print(imgs[j])
print(img.size)

0
build/opt/apps/uengine-runner/icon.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -0,0 +1,97 @@
{
"Url": [
"https://gitee.com/gfdgd-xi/uengine-runner"
],
"Version": "1.4.0",
"System": "Linuxdeepin/UOS",
"Tips": [
" 新版本Deepin/UOS发布后可以在应用商店安装部分官方已适配的安卓应用对爱好者来说不能自己安装APK软件包始终差点意思本程序可以为Deepin/UOS上的Uengine安卓运行环境安装自定义APK软件包并能发送安装的APK包启动菜单到桌面或系统菜单。",
"",
"安装APK点浏览按钮选中需要安装的APK然后点安装按钮",
"",
"卸载APK在卸载APK下面的输入框内输入需要卸载的APK包名点卸载按钮如果无法获取包名可以通过浏览APK文件程序自动获取包名进行卸载。",
"",
"保存APK图标在安装APK下面的输入框浏览或输入APK的路径然后点击“保存图标”按钮选择保存位置即可",
"",
"重置删除uengine数据点击菜单栏的“uengine”的“清空uengine数据”输入密码重启即可",
" 注意如果任何安卓一遍打不开多打开几遍应该就可以重新加载uengine配置了",
"",
"打开Uengine应用列表打开系统已安装的应用列表安卓界面",
"",
"提示:",
"1、需要你有使用 root 权限的能力;",
"2、需要安装 uengine 才能使用;",
"3、提取 apk 图标的 apk 路径以“安装 apk”那栏为准;",
"4、如果想要连接其他手机请使用 1.2.0 以前的版本,可以使用 adb 连接。"
],
"Update": [
"V1.4.0",
"※1、添加新版打包方式deepin打包方式;",
"※2、支持测试运行/创建/删除uengine图标;",
"※3、支持提取安装的apk;",
"※4、支持打包deb包;",
"5、修改菜单栏布局;",
"6、支持打开uengine数据目录和用户数据目录;",
"7、程序信息保存到json,非直接写入程序本体;",
"8、更多命令操作;",
"",
"V.1.3.2",
"※1、支持uengine数据重置;",
"※2、支持修改uengine网络桥接的启动状态;",
"※3、支持右键安装/卸载;",
"※4、支持启用或禁用uengine;",
"※5、修复打包问题不会出现“dpkg:警告:卸载spark-uengine-runner时目录/opt/apps/uengine-runner非空因而不会删除该目录”的错误;",
"",
"V1.3.1",
"※1、修复打包问题防止部分用户安装出错的问题;",
"※2、修复了程序无法提取图标时可以提取默认图标使用;",
"",
"V1.3.0",
"※1、修改了界面布局;",
"※2、修复大多数新安装普通用户的路图标及启动菜单文件路径不存在导致安装APK报错的bugs;",
"3、删除少量冗余代码调整代码顺序;",
"4、支持提取apk图标。",
"",
"V1.2.3",
"1、调整部分控件名称",
"2、调整界面布局及界面风格",
"",
"V1.2.2",
"1、对程序错误的显示更加人性化",
"2、对 icon 的获取方式进行了升级;",
"3、增加了注释、删除部分冗余代码。",
"",
"V1.2.1",
"※1、进行了安装方式的修改不使用 adb修复原无法安装和卸载的问题",
"2、进行了部分优化",
"3、进行了功能缩水",
"4、修复 deb 打包错误。",
"",
"V1.2.0",
"1、支持安装自动添加快捷方式、卸载删除快捷方式",
"2、支持使用包名或 APK 文件卸载程序;",
"3、支持查看安装的所有包名",
"4、进行了部分优化",
"",
"V1.1.0",
"暂无数据",
"",
"V1.0.0",
"暂无数据"
],
"Use": [
"1、uengine相关软件包基于anbox开发",
"2、Python3",
"3、tkintertkinter.tk、ttkthemes、tkinter.messagebox、tkinter.simpledialog、tkinter.filedialog 和 tkinter.ttk",
"4、aapt",
"5、dpkg",
"6、tree",
"7、mkdir",
"8、echo",
"9、chmod",
"……"
],
"Time": "2021年08月19日",
"Contribute": ["gfdgd xi<3025613752@qq.com>",
"actionchen<917981399@qq.com>"]
}

View File

@ -2,8 +2,8 @@
# 使用系统默认的 python3 运行
###########################################################################################
# 作者gfdgd xi
# 版本1.3.2
# 更新时间2021年7月6
# 版本1.3.3
# 更新时间2021年8月19
# 感谢anbox、deepin 和 统信
# 基于 Python3 的 tkinter 构建
###########################################################################################
@ -12,30 +12,26 @@
#################
import os
import sys
import time
import json
import shutil
import random
import zipfile
import traceback
import threading
import webbrowser
import subprocess
import ttkthemes
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
from getxmlimg import getsavexml
def FindApk():
path = filedialog.askopenfilename(title="选择 Apk", filetypes=[("APK 文件", "*.apk"), ("所有文件", "*.*")], initialdir=json.loads(readtxt(get_home() + "/.config/uengine-apk-builder/FindApk.json"))["path"])
path = filedialog.askopenfilename(title="选择 Apk", filetypes=[("APK 文件", "*.apk"), ("所有文件", "*.*")], initialdir=json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkBuild.json"))["path"])
if path != "" and path != "()":
try:
combobox1.set(path)
write_txt(get_home() + "/.config/uengine-apk-builder/FindApk.json", json.dumps({"path": os.path.dirname(path)})) # 写入配置文件
write_txt(get_home() + "/.config/uengine-runner/FindApkBuild.json", json.dumps({"path": os.path.dirname(path)})) # 写入配置文件
except:
pass
@ -183,7 +179,7 @@ Name={}
RunCommandShow("echo '完成!'")
findApkHistory.append(apkPath)
combobox1['value'] = findApkHistory
write_txt(get_home() + "/.config/uengine-apk-builder/FindApkHistory.json", str(json.dumps(ListToDictionary(findApkHistory)))) # 将历史记录的数组转换为字典并写入
write_txt(get_home() + "/.config/uengine-runner/FindApkBuildHistory.json", str(json.dumps(ListToDictionary(findApkHistory)))) # 将历史记录的数组转换为字典并写入
messagebox.showinfo(title="提示", message="打包完成")
DisabledAndEnbled(False)
@ -199,53 +195,11 @@ def GetCommandReturn(cmd):
# cmd 是要获取输出的命令
return subprocess.getoutput(cmd)
# 显示“关于这个程序”窗口
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))
label1 = ttk.Label(message, image=img)
label2 = ttk.Label(message, text=about)
button1 = ttk.Button(message, text="确定", command=mess.withdraw)
label1.pack()
label2.pack()
button1.pack(side="bottom")
message.pack()
mess.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-apk-builder")
ReStartProgram()
except:
traceback.print_exc()
messagebox.showerror(title="错误", message=traceback.format_exc())
# 获取用户主目录
def get_home():
return os.path.expanduser('~')
@ -414,65 +368,37 @@ def get_desktop_path():
def get_home():
return os.path.expanduser('~')
def ShowUseProgram():
global title
global useProgram
messagebox.showinfo(title="{} 使用的程序列表(部分)".format(title), message=useProgram)
###########################
# 程序信息
###########################
programUrl = "https://gitee.com/gfdgd-xi/uengine-runner"
version = "1.3.2"
goodRunSystem = "Linux(deepin/UOS)"
about = '''一个基于 Python3 的 tkinter 制作的 uengine APK 应用打包器
版本:{}
适用平台:{}
tkinter 版本:{}
程序官网:{}
©2021-{} gfdgd xi'''.format(version, goodRunSystem, tk.TkVersion, programUrl, time.strftime("%Y"))
tips = '''提示:
1、无'''
updateThingsString = '''1、无'''
title = "uengine APK 应用打包器 {}".format(version)
updateTime = "2021年8月19日"
updateThings = "{} 更新内容:\n{}\n更新时间{}".format(version, updateThingsString, updateTime, time.strftime("%Y"))
iconPath = "{}/icon.png".format(os.path.split(os.path.realpath(__file__))[0])
useProgram = '''1、uengineanbox
2、Python3
3、tkintertkinter.tk、ttkthemes 和 tkinter.ttk
4、aapt
5、dpkg
6、tree
7、mkdir
8、echo
9、chmod
……'''
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
information = json.loads(readtxt(programPath + "/information.json"))
version = information["Version"]
title = "uengine APK 应用打包器 {}".format(version)
iconPath = "{}/icon.png".format(os.path.split(os.path.realpath(__file__))[0])
###########################
# 加载配置
###########################
if not os.path.exists(get_home() + "/.config/uengine-apk-builder"): # 如果没有配置文件夹
os.mkdir(get_home() + "/.config/uengine-apk-builder") # 创建配置文件夹
if not os.path.exists(get_home() + "/.config/uengine-apk-builder/FindApkHistory.json"): # 如果没有配置文件
write_txt(get_home() + "/.config/uengine-apk-builder/FindApkHistory.json", json.dumps({})) # 创建配置文件
if not os.path.exists(get_home() + "/.config/uengine-apk-builder/FindApk.json"): # 如果没有配置文件
write_txt(get_home() + "/.config/uengine-apk-builder/FindApk.json", json.dumps({"path": "~"})) # 创建配置文件
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/FindApkBuildHistory.json"): # 如果没有配置文件
write_txt(get_home() + "/.config/uengine-runner/FindApkBuildHistory.json", json.dumps({})) # 创建配置文件
if not os.path.exists(get_home() + "/.config/uengine-runner/FindApkBuild.json"): # 如果没有配置文件
write_txt(get_home() + "/.config/uengine-runner/FindApkBuild.json", json.dumps({"path": "~"})) # 创建配置文件
###########################
# 设置变量
###########################
findApkHistory = list(json.loads(readtxt(get_home() + "/.config/uengine-apk-builder/FindApkHistory.json")).values())
findApkHistory = list(json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkBuildHistory.json")).values())
###########################
# 窗口创建
###########################
win = tk.Tk()
checkButtonBool1 = tk.BooleanVar()
style = ttkthemes.ThemedStyle(win)
style.set_theme("adapta")
window = ttk.Frame(win)
style = ttkthemes.ThemedStyle(win)
style.set_theme("breeze")
win.attributes('-alpha', 0.5)
win.title(title)
win.resizable(0, 0)
@ -485,26 +411,8 @@ button3 = ttk.Button(frame2, text="打包", command=BuildDeb)
textbox1 = tk.Text(window, width=100)
menu = tk.Menu(window, background="white") # 设置菜单栏
programmenu = tk.Menu(menu, tearoff=0, background="white") # 设置“程序”菜单栏
#adb = tk.Menu(menu, tearoff=0, background="white")
uengine = 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_separator()
help.add_command(label="小提示", command=helps) # 设置“小提示”项
help.add_command(label="更新内容", command=UpdateThings) # 设置“更新内容”项
help.add_command(label="这个程序使用的程序列表(部分)", command=ShowUseProgram) # 设置“更新内容”项
#help.add_command(label="关于 adb", command=AboutAdb) # 设置“关于这个程序”项
help.add_command(label="关于这个程序", command=about_this_program) # 设置“关于这个程序”项
menu.configure(activebackground="white")
help.configure(activebackground="white")
uengine.configure(activebackground="white")
#adb.configure(activebackground="white")
programmenu.configure(activebackground="white")
# 设置控件
combobox1['value'] = findApkHistory
textbox1.configure(state=tk.DISABLED)

View File

@ -11,6 +11,7 @@
#################
# 引入所需的库
#################
from genericpath import exists
import os
import sys
import time
@ -26,6 +27,7 @@ import tkinter as tk
import tkinter.ttk as ttk
import tkinter.messagebox as messagebox
import tkinter.filedialog as filedialog
import tkinter.simpledialog as simpledialog
from getxmlimg import getsavexml
from tkinter.constants import TOP
@ -46,6 +48,7 @@ def UninstallProgram(package: "apk 包名")->"卸载程序":
traceback.print_exc()
messagebox.showerror(title="错误", message=traceback.format_exc())
# 卸载文本框的浏览按钮事件
def BtnFindUninstallApkClk():
path = filedialog.askopenfilename(title="选择 Apk", filetypes=[("APK 文件", "*.apk"), ("所有文件", "*.*")], initialdir=json.loads(readtxt(get_home() + "/.config/uengine-runner/FindUninstallApk.json"))["path"])
if path != "" and path != "()":
@ -55,6 +58,7 @@ def BtnFindUninstallApkClk():
except:
pass
# 卸载按钮事件
def ButtonClick8():
if ComboUninstallPath.get() is "":
messagebox.showerror(title="提示", message="信息没有填写完整,无法继续卸载 APK")
@ -83,6 +87,7 @@ def FindApk()->"浏览窗口":
except:
pass
# 安装按钮事件
def Button3Install():
if ComboInstallPath.get() is "":
messagebox.showerror(title="提示", message="信息没有填写完整,无法继续安装 APK")
@ -139,6 +144,7 @@ def DisabledAndEnbled(choose: "启动或者禁用")->"禁用或启动所有控
BtnUninstallApkBrowser.configure(state=a)
BtnUninstall.configure(state=a)
Btngeticon.configure(state=a)
BtnSaveApk.configure(state=a)
# 需引入 subprocess
# 运行系统命令并获取返回值
@ -146,6 +152,7 @@ def GetCommandReturn(cmd: "命令")->"运行系统命令并获取返回值":
# cmd 是要获取输出的命令
return subprocess.getoutput(cmd)
# 打开所有窗口事件
def Button5Click():
threading.Thread(target=OpenUengineProgramList).start()
@ -334,11 +341,8 @@ def GetApkChineseLabel(apkFilePath)->"获取软件的中文名称":
line = line.replace("'", "")
return line
# 获取图标在包内的路径
#def GetApkIconInApk(apkFilePath)->"获取图标在包内的路径":
#合并两个函数到一起
def SaveApkIcon(apkFilePath, iconSavePath)->"获取 apk 文件的图标":
# 保存apk图标
def SaveApkIcon(apkFilePath, iconSavePath)->"保存 apk 文件的图标":
try:
info = GetApkInformation(apkFilePath)
for line in info.split('\n'):
@ -365,6 +369,7 @@ def saveicon():
print(iconSavePath+"iconpaths")
SaveApkIcon(temppath, iconSavePath)
# 用户自行保存APK
def SaveIconToOtherPath():
apkPath = ComboInstallPath.get()
if apkPath == "":
@ -384,13 +389,7 @@ def SaveIconToOtherPath():
write_txt(get_home() + "/.config/uengine-runner/FindApkHistory.json", str(json.dumps(ListToDictionary(findApkHistory)))) # 将历史记录的数组转换为字典并写入
messagebox.showinfo(title="提示", message="保存成功!")
## 获取 apk 文件的图标(部分程序不支持)
# def SaveApkIcon(apkFilePath, iconSavePath)->"获取 apk 文件的图标(部分程序不支持)":
# zip = zipfile.ZipFile(apkFilePath)
# iconData = zip.read(GetApkIconInApk(apkFilePath))
# with open(iconSavePath, 'w+b') as saveIconFile:
# saveIconFile.write(iconData)
# 清空 uengine 数据
def BackUengineClean()->"清空 uengine 数据":
print("Choose")
if messagebox.askokcancel(title="警告", message="清空后数据将会完全丢失,确定要继续吗?"):
@ -405,32 +404,57 @@ def BackUengineClean()->"清空 uengine 数据":
return
print("Choose False")
def UengineBridgeStart():
# 启用 uengine 网络桥接
def UengineBridgeStart()->"启用 uengine 网络桥接":
DisabledAndEnbled(True)
os.system("pkexec uengine-bridge.sh start")
DisabledAndEnbled(False)
def UengineBridgeStop():
# 关闭 uengine 网络桥接
def UengineBridgeStop()->"关闭 uengine 网络桥接":
DisabledAndEnbled(True)
os.system("pkexec uengine-bridge.sh stop")
DisabledAndEnbled(False)
def UengineBridgeRestart():
# 重启 uengine 网络桥接
def UengineBridgeRestart()->"重启 uengine 网络桥接":
DisabledAndEnbled(True)
os.system("pkexec uengine-bridge.sh restart")
DisabledAndEnbled(False)
def UengineBridgeReload():
# 加载 uengine 网络桥接
def UengineBridgeReload()->"加载 uengine 网络桥接":
DisabledAndEnbled(True)
os.system("pkexec uengine-bridge.sh reload")
DisabledAndEnbled(False)
def UengineBridgeForceReload():
# 强制加载 uengine 网络桥接
def UengineBridgeForceReload()->"强制加载 uengine 网络桥接":
DisabledAndEnbled(True)
os.system("pkexec uengine-bridge.sh force-reload")
DisabledAndEnbled(False)
# 启用 uengine 服务
def StartUengine()->"启用 uengine 服务":
DisabledAndEnbled(True)
os.system("systemctl enable uengine-container uengine-session && systemctl start uengine-container uengine-session")
DisabledAndEnbled(False)
# 关闭 uengine 服务
def StopUengine()->"关闭 uengine 服务":
DisabledAndEnbled(True)
os.system("systemctl disable uengine-container uengine-session")
DisabledAndEnbled(False)
# 重启 uengine 服务
def UengineRestart()->"重启 uengine 服务":
DisabledAndEnbled(True)
os.system("systemctl restart uengine*")
DisabledAndEnbled(False)
# 运行命令的窗口
class InstallWindow():
# 显示窗口
def ShowWindows(command):
global message
global text
@ -454,6 +478,7 @@ class InstallWindow():
threading.Thread(target=InstallWindow.RunCommand, args=[command]).start()
message.mainloop()
# 运行命令并显示
def RunCommand(command):
global message
global text
@ -475,6 +500,7 @@ class InstallWindow():
print("reboot")
os.system("reboot")
# 添加文本
def AddText(things):
global text
text.configure(state=tk.NORMAL)
@ -497,24 +523,161 @@ def get_desktop_path()->"获取用户桌面目录":
get = get.replace("$HOME", get_home()) # 则把其替换为用户目录(~)
return get # 返回目录
# 提取已安装程序的apk
def SaveInstallUengineApp():
while True:
result = simpledialog.askstring(title="输入apk包名", prompt="请输入要获取的apk包名以便进行下一步操作")
if result == "" or result == None:
return
if os.path.exists("/data/uengine/data/data/app/{}-1".format(result)):
break
messagebox.showerror(title="错误", message="路径不存在,请重试!")
path = filedialog.asksaveasfilename(title="保存apk", filetypes=[("APK 文件", "*.apk"), ("所有文件", "*.*")], initialdir=json.loads(readtxt(get_home() + "/.config/uengine-runner/SaveApk.json"))["path"])
if path == "" or path == ():
return
try:
shutil.copy("/data/uengine/data/data/app/{}-1/base.apk".format(result), path)
write_txt(get_home() + "/.config/uengine-runner/SaveApk.json", json.dumps({"path": os.path.dirname(path)}))
messagebox.showinfo(title="提示", message="提取完成!")
except:
traceback.print_exc()
messagebox.showerror(title="错误", message=traceback.format_exc())
# 获取用户主目录
def get_home()->"获取用户主目录":
return os.path.expanduser('~')
def StartUengine():
os.system("systemctl enable uengine-container uengine-session && systemctl start uengine-container uengine-session")
# 删除所有的 uengine 应用快捷方式
def CleanAllUengineDesktopLink():
if messagebox.askokcancel(title="提示", message="你确定要删除所有的 uengine 应用快捷方式吗?"):
try:
shutil.rmtree("{}/.local/share/applications/uengine".format(get_home()))
os.mkdir("{}/.local/share/applications/uengine".format(get_home()))
messagebox.showinfo(title="提示", message="删除完毕!")
except:
traceback.print_exc()
messagebox.showerror(title="错误", message=traceback.format_exc())
def StopUengine():
os.system("systemctl disable uengine-container uengine-session")
# 打开 uengine 应用打包器
def OpenUengineDebBuilder():
threading.Thread(target=os.system, args=[programPath + "/uengine-apk-builder"]).start()
# 打开 uengine 根目录
def OpenUengineRootData():
threading.Thread(target=os.system, args=["xdg-open /data/uengine/data/data"]).start()
# 打开 uengine 用户数据目录
def OpenUengineUserData():
threading.Thread(target=os.system, args=["xdg-open ~/安卓应用文件"]).start()
# 添加/删除 uengine 应用快捷方式
class AddNewUengineDesktopLink():
addTips = '''可以输入app的包名和Activity或通过浏览apk文件来获取包名和Activity
注意:如果是要删除只要输入包名即可'''
def ShowWindow():
global activityName
global packageName
message = tk.Toplevel()
tipsLabel = ttk.Label(message, text=AddNewUengineDesktopLink.addTips)
packageName = ttk.Combobox(message, width=30)
activityName = ttk.Combobox(message, width=30)
findApk = ttk.Button(message, text="浏览", command=AddNewUengineDesktopLink.FindApk)
controlFrame = ttk.Frame(message)
testOpen = ttk.Button(controlFrame, text="打开", command=AddNewUengineDesktopLink.TestOpen)
saveButton = ttk.Button(controlFrame, text="写入", command=AddNewUengineDesktopLink.SaveDesktopLink)
delButton = ttk.Button(controlFrame, text="删除", command=AddNewUengineDesktopLink.DelDesktopLink)
message.title("添加/删除 uengine 图标")
message.resizable(0, 0)
# get screen width and height
screen_width = message.winfo_screenwidth()
screen_height = message.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)
message.geometry("+{}+{}".format(int(x), int(y)))
packageName["value"] = findApkNameHistory
activityName["value"] = findApkActivityHistory
tipsLabel.grid(row=0, column=0, columnspan=3)
packageName.grid(row=1, column=0)
activityName.grid(row=1, column=1)
findApk.grid(row=1, column=2)
controlFrame.grid(row=2, column=0, columnspan=3)
testOpen.grid(row=0, column=0)
saveButton.grid(row=0, column=1)
delButton.grid(row=0, column=2)
message.mainloop()
# 添加快捷方式
def SaveDesktopLink():
if os.path.exists("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get())):
if not messagebox.askokcancel(title="提示", message="文件已存在,确定要覆盖吗?"):
return
global activityName
iconSavePath = "{}/.local/share/icons/hicolor/256x256/apps/{}.png".format(get_home(), packageName.get())
shutil.copy(programPath + "/defult.png", iconSavePath)
BuildUengineDesktop(packageName.get(), activityName, packageName.get(), iconSavePath,
"{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get()))
BuildUengineDesktop(packageName.get(), activityName, packageName.get(), iconSavePath,
"{}/{}.desktop".format(get_desktop_path(), packageName.get()))
AddNewUengineDesktopLink.SaveHistory()
messagebox.showinfo(title="提示", message="创建完毕!")
# 删除快捷方式
def DelDesktopLink():
global packageName
if not os.path.exists("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get())):
messagebox.showerror(title="错误", message="此包名对应的uengine桌面快捷方式不存在")
return
if not messagebox.askyesno(title="提示", message="你确定要删除吗?删除后将无法恢复!"):
return
try:
os.remove("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get()))
AddNewUengineDesktopLink.SaveHistory()
messagebox.showinfo(title="提示", message="已删除")
except:
traceback.print_exc()
messagebox.showerror(title="错误", message=traceback.format_exc())
# 保存历史记录
def SaveHistory():
findApkNameHistory.append(packageName.get())
findApkActivityHistory.append(activityName.get())
packageName['value'] = findApkNameHistory
activityName['value'] = findApkActivityHistory
write_txt(get_home() + "/.config/uengine-runner/FindApkNameHistory.json", str(json.dumps(ListToDictionary(findApkNameHistory)))) # 将历史记录的数组转换为字典并写入
write_txt(get_home() + "/.config/uengine-runner/FindApkActivityHistory.json", str(json.dumps(ListToDictionary(findApkActivityHistory)))) # 将历史记录的数组转换为字典并写入
# 打开测试
def TestOpen():
threading.Thread(target=os.system, args=["/usr/bin/uengine-launch.sh --package={} --component={}".format(packageName.get(), activityName.get())]).start()
AddNewUengineDesktopLink.SaveHistory()
# 浏览文件
def FindApk():
path = filedialog.askopenfilename(title="选择apk", filetypes=[("APK 文件", "*.apk"), ("所有文件", "*.*")], initialdir=json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkName.json"))["path"])
if path == "" or path == ():
return
packageName.set(GetApkPackageName(path))
activityName.set(GetApkActivityName(path))
write_txt(get_home() + "/.config/uengine-runner/FindApkName.json", json.dumps({"path": os.path.dirname(path)})) # 写入配置文件
###########################
# 程序信息
###########################
programUrl = "https://gitee.com/gfdgd-xi/uengine-runner"
version = "1.3.2"
goodRunSystem = "Linuxdeepin/UOS"
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")
about = ''' 一个基于 Python3 的 tkinter 制作的 uengine APK 安装器
about = ''' 一个基于 Python3 的 tkinter 制作的 uengine APK 运行
版本 {}
@ -527,70 +690,17 @@ aapt 版本 {}
程序官网 {}
©2021-{}'''.format(version, goodRunSystem, tk.TkVersion, aaptVersion,programUrl, time.strftime("%Y"))
tips = ''' 新版本Deepin/UOS发布后可以在应用商店安装部分官方已适配的安卓应用对爱好者来说不能自己安装APK软件包始终差点意思本程序可以为Deepin/UOS上的Uengine安卓运行环境安装自定义APK软件包并能发送安装的APK包启动菜单到桌面或系统菜单。
安装APK
点浏览按钮选中需要安装的APK然后点安装按钮
卸载APK
在卸载APK下面的输入框内输入需要卸载的APK包名点卸载按钮如果无法获取包名可以通过浏览APK文件程序自动获取包名进行卸载。
保存APK图标
在安装APK下面的输入框浏览或输入APK的路径然后点击“保存图标”按钮选择保存位置即可
重置删除uengine 数据:
点击菜单栏的“uengine”的“清空uengine数据”输入密码重启即可
注意如果任何安卓一遍打不开多打开几遍应该就可以重新加载uengine配置了
打开Uengine应用列表
打开系统已安装的应用列表(安卓界面)
提示:
1、需要你有使用 root 权限的能力;
2、需要安装 uengine 才能使用;
3、提取 apk 图标的 apk 路径以“安装 apk”那栏为准;
4、如果想要连接其他手机请使用 1.2.0 以前的版本,可以使用 adb 连接。
'''
updateThingsString = '''V.1.3.2
※1、支持uengine数据重置;
※2、支持修改uengine网络桥接的启动状态;
※3、支持右键安装/卸载;
※4、支持启用或禁用uengine;
※5、修复打包问题不会出现“dpkg:警告:卸载spark-uengine-runner时目录/opt/apps/uengine-runner非空因而不会删除该目录”的错误;
V1.3.1
※1、修复打包问题防止部分用户安装出错的问题;
※2、修复了程序无法提取图标时可以提取默认图标使用;
V1.3.0
※1、修改了界面布局;
※2、修复大多数新安装普通用户的路图标及启动菜单文件路径不存在导致安装APK报错的bugs;
3、删除少量冗余代码调整代码顺序;
4、支持提取apk图标。
V1.2.3
1、调整部分控件名称
2、调整界面布局及界面风格
V1.2.2
1、对程序错误的显示更加人性化
2、对icon的获取方式进行了升级
3、增加了注释、删除部分冗余代码。
'''
title = "uengine 安装器 {}".format(version)
updateTime = "2021年08月15日"
tips = "\n".join(information["Tips"])
updateThingsString = "\n".join(information["Update"])
title = "uengine 运行器 {}".format(version)
updateTime = information["Time"]
updateThings = "{} 更新内容:\n{}\n更新时间{}".format(version, updateThingsString, updateTime, time.strftime("%Y"))
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
iconPath = "{}/icon.png".format(os.path.split(os.path.realpath(__file__))[0])
desktop = "/opt/apps/uengine-runner/UengineAndroidProgramList.desktop"
desktopName = "UengineAndroidProgramList.desktop"
contribute = '''gfdgd xi<3025613752@qq.com>
actionchen<917981399@qq.com>'''
useProgram = '''1、uengine相关软件包基于anbox开发
2、Python3
3、tkintertkinter.tk、ttkthemes 和 tkinter.ttk
4、aapt
……'''
contribute = "\n".join(information["Contribute"])
useProgram = "\n".join(information["Use"])
###########################
# 加载配置
@ -601,20 +711,30 @@ 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/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())
fineUninstallApkHistory = list(json.loads(readtxt(get_home() + "/.config/uengine-runner/FindUninstallApkHistory.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
#添加窗口开启关闭开关,防止重复开启
@ -741,7 +861,8 @@ BtnInstall = ttk.Button(FrmInstall, text="安装", command=Button3Install)
BtnShowUengineApp = ttk.Button(window, text="打开 uengine 应用列表", command=Button5Click)
BtnUninstallApkBrowser = ttk.Button(FrmUninstall, text="浏览", command=BtnFindUninstallApkClk)
BtnUninstall = ttk.Button(FrmUninstall, text="卸载", command=ButtonClick8)
Btngeticon = ttk.Button(window, text="保存图标", command=SaveIconToOtherPath)
Btngeticon = ttk.Button(FrmInstall, text="保存图标", command=SaveIconToOtherPath)
BtnSaveApk = ttk.Button(FrmInstall, text="保存apk", command=SaveInstallUengineApp)
# 设置菜单栏
menu = tk.Menu(window, background="white")
@ -749,6 +870,11 @@ programmenu = tk.Menu(menu, tearoff=0, background="white") # 设置“程序”
uengine = tk.Menu(menu, tearoff=0, background="white")
help = tk.Menu(menu, tearoff=0, background="white") # 设置“帮助”菜单栏
uengineService = tk.Menu(uengine)
uengineInternet = tk.Menu(uengine)
uengineIcon = tk.Menu(uengine)
uengineData = tk.Menu(uengine)
menu.add_cascade(label="程序", menu=programmenu)
menu.add_cascade(label="uengine", menu=uengine)
menu.add_cascade(label="关于", menu=help)
@ -757,28 +883,44 @@ programmenu.add_command(label="清空软件历史记录", command=CleanProgramHi
programmenu.add_separator() # 设置分界线
programmenu.add_command(label="退出程序", command=window.quit) # 设置“退出程序”
uengine.add_command(label="发送 uengine 应用列表到桌面", command=SendUengineAndroidListForDesktop)
uengine.add_command(label="发送 uengine 应用列表到启动器", command=SendUengineAndroidListForLauncher)
uengine.add_separator()
uengine.add_command(label="启用 uengine", command=StartUengine)
uengine.add_command(label="禁用 uengine", command=StopUengine)
uengine.add_separator()
uengine.add_command(label="启用 uengine 网络桥接", command=UengineBridgeStart)
uengine.add_command(label="关闭 uengine 网络桥接", command=UengineBridgeStop)
uengine.add_command(label="重启 uengine 网络桥接", command=UengineBridgeRestart)
uengine.add_command(label="加载 uengine 网络桥接", command=UengineBridgeReload)
uengine.add_command(label="强制加载 uengine 网络桥接", command=UengineBridgeForceReload)
uengine.add_separator()
uengine.add_command(label="清空 uengine 数据", command=BackUengineClean)
uengine.add_command(label="uengine 应用打包", command=OpenUengineDebBuilder)
uengine.add_cascade(label="uengine 服务", menu=uengineService)
uengine.add_cascade(label="uengine 网络桥接", menu=uengineInternet)
uengine.add_cascade(label="uengine 快捷方式", menu=uengineIcon)
uengine.add_cascade(label="uengine 数据", menu=uengineData)
help.add_command(label="程序官网", command=OpenProgramURL) # 设置“程序官网”项
help.add_command(label="帮助", command=showhelp) # 设置“关于这个程序”项
uengineService.add_command(label="启用 uengine 服务", command=StartUengine)
uengineService.add_command(label="关闭 uengine 服务", command=StopUengine)
uengineService.add_command(label="重启 uengine 服务", command=UengineRestart)
uengineInternet.add_command(label="启用 uengine 网络桥接", command=UengineBridgeStart)
uengineInternet.add_command(label="关闭 uengine 网络桥接", command=UengineBridgeStop)
uengineInternet.add_command(label="重启 uengine 网络桥接", command=UengineBridgeRestart)
uengineInternet.add_command(label="加载 uengine 网络桥接", command=UengineBridgeReload)
uengineInternet.add_command(label="强制加载 uengine 网络桥接", command=UengineBridgeForceReload)
uengineIcon.add_command(label="发送 uengine 应用列表到桌面", command=SendUengineAndroidListForDesktop)
uengineIcon.add_command(label="发送 uengine 应用列表到启动器", command=SendUengineAndroidListForLauncher)
uengineIcon.add_separator()
uengineIcon.add_command(label="添加/删除指定的 uengine 快捷方式", command=AddNewUengineDesktopLink.ShowWindow)
uengineIcon.add_separator()
uengineIcon.add_command(label="清空所有 uengine 快捷方式", command=CleanAllUengineDesktopLink)
uengineData.add_command(label="打开 uengine 根目录", command=OpenUengineRootData)
uengineData.add_command(label="打开 uengine 用户数据目录", command=OpenUengineUserData)
uengineData.add_separator()
uengineData.add_command(label="清空 uengine 数据", command=BackUengineClean)
menu.configure(activebackground="dodgerblue")
help.configure(activebackground="dodgerblue")
uengine.configure(activebackground="dodgerblue")
programmenu.configure(activebackground="dodgerblue")
uengineService.configure(activebackground="dodgerblue")
uengineInternet.configure(activebackground="dodgerblue")
uengineIcon.configure(activebackground="dodgerblue")
# 设置控件
ComboUninstallPath['value'] = fineUninstallApkHistory
@ -803,20 +945,21 @@ LabApkPath.grid(row=1, column=0,sticky= tk.W,padx=3)
ComboInstallPath.grid(row=2, column=0,padx=3)
FrmInstall.grid(row=2, column=1,padx=3)
FrmInstall.grid(row=2, column=1,padx=3, rowspan=2)
BtnFindApk.grid(row=0, column=0)
BtnInstall.grid(row=0, column=1)
LabUninstallPath.grid(row=3, column=0,sticky= tk.W,padx=3)
ComboUninstallPath.grid(row=4, column=0,padx=3)
LabUninstallPath.grid(row=4, column=0,sticky= tk.W,padx=3)
ComboUninstallPath.grid(row=5, column=0,padx=3)
FrmUninstall.grid(row=4, column=1,padx=3)
FrmUninstall.grid(row=5, column=1,padx=3)
BtnUninstallApkBrowser.grid(row=0, column=0)
BtnUninstall.grid(row=0, column=1)
BtnShowUengineApp.grid(row=5, column=0,sticky= tk.W,padx=3,pady=2)
BtnShowUengineApp.grid(row=6, column=0,sticky= tk.W,padx=3,pady=2)
Btngeticon.grid(row=3, column=1,sticky= tk.W,padx=3,pady=2)
Btngeticon.grid(row=1, column=0,sticky= tk.W,padx=3,pady=2)
BtnSaveApk.grid(row=1, column=1,sticky= tk.W,padx=3,pady=2)
window.pack()

View File

@ -0,0 +1,148 @@
#!/usr/bin/env python3
# 使用系统默认的 python3 运行
###########################################################################################
# 作者gfdgd xi
# 版本1.3.3
# 更新时间2021年8月19日
# 感谢anbox、deepin 和 统信
# 基于 Python3 的 tkinter 构建
###########################################################################################
#################
# 引入所需的库
#################
import os
import time
import json
import ttkthemes
import subprocess
import tkinter as tk
import tkinter.ttk as ttk
# 读取文本文档
def readtxt(path: "路径")->"读取文本文档":
f = open(path, "r") # 设置文件对象
str = f.read() # 获取内容
f.close() # 关闭文本对象
return str # 返回结果
###########################
# 程序信息
###########################
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 = subprocess.getoutput("aapt version")
about = ''' 一个基于 Python3 的 tkinter 制作的 uengine APK 运行器
版本 {}
适用平台 {}
tkinter版本{}
aapt 版本 {}
程序官网 {}
©2021-{}'''.format(version, goodRunSystem, tk.TkVersion, aaptVersion,programUrl, time.strftime("%Y"))
tips = "\n".join(information["Tips"])
updateThingsString = "\n".join(information["Update"])
title = "uengine 运行器 {}".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 = "/opt/apps/uengine-runner/UengineAndroidProgramList.desktop"
desktopName = "UengineAndroidProgramList.desktop"
contribute = "\n".join(information["Contribute"])
useProgram = "\n".join(information["Use"])
# add sub window
#添加窗口开启关闭开关,防止重复开启
windowflag = "close"
def showhelp():
#define window and frame and button label
#
global windowflag
if windowflag == "close":
helpwindow=tk.Tk()
helpwindow.resizable(0, 0)
helpwindow.title("帮助")
# 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))
helpwindow.iconphoto(False, tk.PhotoImage(file=iconPath))
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 ChgDep():
HelpStr.set(useProgram)
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)
BtnZujian = ttk.Button(FrmMenu, text="程序依赖的组件",width=14,command=ChgDep)
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)
BtnZujian.grid(row=2,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)
showhelp()

View File

@ -0,0 +1 @@
/opt/apps/uengine-runner/uengine-apk-builder

View File

@ -0,0 +1 @@
/opt/apps/uengine-runner/uengine-app-install

View File

@ -0,0 +1 @@
/opt/apps/uengine-runner/uengine-app-uninstall

1
build/usr/bin/uengine-clean Symbolic link
View File

@ -0,0 +1 @@
/opt/apps/uengine-runner/uengine-clean

View File

@ -0,0 +1 @@
/opt/apps/uengine-runner/uengine-runner-about

Binary file not shown.

97
information.json Normal file
View File

@ -0,0 +1,97 @@
{
"Url": [
"https://gitee.com/gfdgd-xi/uengine-runner"
],
"Version": "1.4.0",
"System": "Linuxdeepin/UOS",
"Tips": [
" 新版本Deepin/UOS发布后可以在应用商店安装部分官方已适配的安卓应用对爱好者来说不能自己安装APK软件包始终差点意思本程序可以为Deepin/UOS上的Uengine安卓运行环境安装自定义APK软件包并能发送安装的APK包启动菜单到桌面或系统菜单。",
"",
"安装APK点浏览按钮选中需要安装的APK然后点安装按钮",
"",
"卸载APK在卸载APK下面的输入框内输入需要卸载的APK包名点卸载按钮如果无法获取包名可以通过浏览APK文件程序自动获取包名进行卸载。",
"",
"保存APK图标在安装APK下面的输入框浏览或输入APK的路径然后点击“保存图标”按钮选择保存位置即可",
"",
"重置删除uengine数据点击菜单栏的“uengine”的“清空uengine数据”输入密码重启即可",
" 注意如果任何安卓一遍打不开多打开几遍应该就可以重新加载uengine配置了",
"",
"打开Uengine应用列表打开系统已安装的应用列表安卓界面",
"",
"提示:",
"1、需要你有使用 root 权限的能力;",
"2、需要安装 uengine 才能使用;",
"3、提取 apk 图标的 apk 路径以“安装 apk”那栏为准;",
"4、如果想要连接其他手机请使用 1.2.0 以前的版本,可以使用 adb 连接。"
],
"Update": [
"V1.4.0",
"※1、添加新版打包方式deepin打包方式;",
"※2、支持测试运行/创建/删除uengine图标;",
"※3、支持提取安装的apk;",
"※4、支持打包deb包;",
"5、修改菜单栏布局;",
"6、支持打开uengine数据目录和用户数据目录;",
"7、程序信息保存到json,非直接写入程序本体;",
"8、更多命令操作;",
"",
"V.1.3.2",
"※1、支持uengine数据重置;",
"※2、支持修改uengine网络桥接的启动状态;",
"※3、支持右键安装/卸载;",
"※4、支持启用或禁用uengine;",
"※5、修复打包问题不会出现“dpkg:警告:卸载spark-uengine-runner时目录/opt/apps/uengine-runner非空因而不会删除该目录”的错误;",
"",
"V1.3.1",
"※1、修复打包问题防止部分用户安装出错的问题;",
"※2、修复了程序无法提取图标时可以提取默认图标使用;",
"",
"V1.3.0",
"※1、修改了界面布局;",
"※2、修复大多数新安装普通用户的路图标及启动菜单文件路径不存在导致安装APK报错的bugs;",
"3、删除少量冗余代码调整代码顺序;",
"4、支持提取apk图标。",
"",
"V1.2.3",
"1、调整部分控件名称",
"2、调整界面布局及界面风格",
"",
"V1.2.2",
"1、对程序错误的显示更加人性化",
"2、对 icon 的获取方式进行了升级;",
"3、增加了注释、删除部分冗余代码。",
"",
"V1.2.1",
"※1、进行了安装方式的修改不使用 adb修复原无法安装和卸载的问题",
"2、进行了部分优化",
"3、进行了功能缩水",
"4、修复 deb 打包错误。",
"",
"V1.2.0",
"1、支持安装自动添加快捷方式、卸载删除快捷方式",
"2、支持使用包名或 APK 文件卸载程序;",
"3、支持查看安装的所有包名",
"4、进行了部分优化",
"",
"V1.1.0",
"暂无数据",
"",
"V1.0.0",
"暂无数据"
],
"Use": [
"1、uengine相关软件包基于anbox开发",
"2、Python3",
"3、tkintertkinter.tk、ttkthemes、tkinter.messagebox、tkinter.simpledialog、tkinter.filedialog 和 tkinter.ttk",
"4、aapt",
"5、dpkg",
"6、tree",
"7、mkdir",
"8、echo",
"9、chmod",
"……"
],
"Time": "2021年08月19日",
"Contribute": ["gfdgd xi<3025613752@qq.com>",
"actionchen<917981399@qq.com>"]
}

158
main.py
View File

@ -48,6 +48,7 @@ def UninstallProgram(package: "apk 包名")->"卸载程序":
traceback.print_exc()
messagebox.showerror(title="错误", message=traceback.format_exc())
# 卸载文本框的浏览按钮事件
def BtnFindUninstallApkClk():
path = filedialog.askopenfilename(title="选择 Apk", filetypes=[("APK 文件", "*.apk"), ("所有文件", "*.*")], initialdir=json.loads(readtxt(get_home() + "/.config/uengine-runner/FindUninstallApk.json"))["path"])
if path != "" and path != "()":
@ -57,6 +58,7 @@ def BtnFindUninstallApkClk():
except:
pass
# 卸载按钮事件
def ButtonClick8():
if ComboUninstallPath.get() is "":
messagebox.showerror(title="提示", message="信息没有填写完整,无法继续卸载 APK")
@ -85,6 +87,7 @@ def FindApk()->"浏览窗口":
except:
pass
# 安装按钮事件
def Button3Install():
if ComboInstallPath.get() is "":
messagebox.showerror(title="提示", message="信息没有填写完整,无法继续安装 APK")
@ -149,6 +152,7 @@ def GetCommandReturn(cmd: "命令")->"运行系统命令并获取返回值":
# cmd 是要获取输出的命令
return subprocess.getoutput(cmd)
# 打开所有窗口事件
def Button5Click():
threading.Thread(target=OpenUengineProgramList).start()
@ -337,11 +341,8 @@ def GetApkChineseLabel(apkFilePath)->"获取软件的中文名称":
line = line.replace("'", "")
return line
# 获取图标在包内的路径
#def GetApkIconInApk(apkFilePath)->"获取图标在包内的路径":
#合并两个函数到一起
def SaveApkIcon(apkFilePath, iconSavePath)->"获取 apk 文件的图标":
# 保存apk图标
def SaveApkIcon(apkFilePath, iconSavePath)->"保存 apk 文件的图标":
try:
info = GetApkInformation(apkFilePath)
for line in info.split('\n'):
@ -368,6 +369,7 @@ def saveicon():
print(iconSavePath+"iconpaths")
SaveApkIcon(temppath, iconSavePath)
# 用户自行保存APK
def SaveIconToOtherPath():
apkPath = ComboInstallPath.get()
if apkPath == "":
@ -387,13 +389,7 @@ def SaveIconToOtherPath():
write_txt(get_home() + "/.config/uengine-runner/FindApkHistory.json", str(json.dumps(ListToDictionary(findApkHistory)))) # 将历史记录的数组转换为字典并写入
messagebox.showinfo(title="提示", message="保存成功!")
## 获取 apk 文件的图标(部分程序不支持)
# def SaveApkIcon(apkFilePath, iconSavePath)->"获取 apk 文件的图标(部分程序不支持)":
# zip = zipfile.ZipFile(apkFilePath)
# iconData = zip.read(GetApkIconInApk(apkFilePath))
# with open(iconSavePath, 'w+b') as saveIconFile:
# saveIconFile.write(iconData)
# 清空 uengine 数据
def BackUengineClean()->"清空 uengine 数据":
print("Choose")
if messagebox.askokcancel(title="警告", message="清空后数据将会完全丢失,确定要继续吗?"):
@ -408,47 +404,57 @@ def BackUengineClean()->"清空 uengine 数据":
return
print("Choose False")
# 启用 uengine 网络桥接
def UengineBridgeStart()->"启用 uengine 网络桥接":
DisabledAndEnbled(True)
os.system("pkexec uengine-bridge.sh start")
DisabledAndEnbled(False)
# 关闭 uengine 网络桥接
def UengineBridgeStop()->"关闭 uengine 网络桥接":
DisabledAndEnbled(True)
os.system("pkexec uengine-bridge.sh stop")
DisabledAndEnbled(False)
# 重启 uengine 网络桥接
def UengineBridgeRestart()->"重启 uengine 网络桥接":
DisabledAndEnbled(True)
os.system("pkexec uengine-bridge.sh restart")
DisabledAndEnbled(False)
# 加载 uengine 网络桥接
def UengineBridgeReload()->"加载 uengine 网络桥接":
DisabledAndEnbled(True)
os.system("pkexec uengine-bridge.sh reload")
DisabledAndEnbled(False)
# 强制加载 uengine 网络桥接
def UengineBridgeForceReload()->"强制加载 uengine 网络桥接":
DisabledAndEnbled(True)
os.system("pkexec uengine-bridge.sh force-reload")
DisabledAndEnbled(False)
# 启用 uengine 服务
def StartUengine()->"启用 uengine 服务":
DisabledAndEnbled(True)
os.system("systemctl enable uengine-container uengine-session && systemctl start uengine-container uengine-session")
DisabledAndEnbled(False)
# 关闭 uengine 服务
def StopUengine()->"关闭 uengine 服务":
DisabledAndEnbled(True)
os.system("systemctl disable uengine-container uengine-session")
DisabledAndEnbled(False)
# 重启 uengine 服务
def UengineRestart()->"重启 uengine 服务":
DisabledAndEnbled(True)
os.system("systemctl restart uengine*")
DisabledAndEnbled(False)
# 运行命令的窗口
class InstallWindow():
# 显示窗口
def ShowWindows(command):
global message
global text
@ -472,6 +478,7 @@ class InstallWindow():
threading.Thread(target=InstallWindow.RunCommand, args=[command]).start()
message.mainloop()
# 运行命令并显示
def RunCommand(command):
global message
global text
@ -493,6 +500,7 @@ class InstallWindow():
print("reboot")
os.system("reboot")
# 添加文本
def AddText(things):
global text
text.configure(state=tk.NORMAL)
@ -515,6 +523,7 @@ def get_desktop_path()->"获取用户桌面目录":
get = get.replace("$HOME", get_home()) # 则把其替换为用户目录(~)
return get # 返回目录
# 提取已安装程序的apk
def SaveInstallUengineApp():
while True:
result = simpledialog.askstring(title="输入apk包名", prompt="请输入要获取的apk包名以便进行下一步操作")
@ -534,14 +543,13 @@ def SaveInstallUengineApp():
traceback.print_exc()
messagebox.showerror(title="错误", message=traceback.format_exc())
# 获取用户主目录
def get_home()->"获取用户主目录":
return os.path.expanduser('~')
# 删除所有的 uengine 应用快捷方式
def CleanAllUengineDesktopLink():
if messagebox.askokcancel(title="提示", message="你确定要删除所有的 uengine 快捷方式吗?"):
if messagebox.askokcancel(title="提示", message="你确定要删除所有的 uengine 应用快捷方式吗?"):
try:
shutil.rmtree("{}/.local/share/applications/uengine".format(get_home()))
os.mkdir("{}/.local/share/applications/uengine".format(get_home()))
@ -550,6 +558,19 @@ def CleanAllUengineDesktopLink():
traceback.print_exc()
messagebox.showerror(title="错误", message=traceback.format_exc())
# 打开 uengine 应用打包器
def OpenUengineDebBuilder():
threading.Thread(target=os.system, args=[programPath + "/uengine-apk-builder"]).start()
# 打开 uengine 根目录
def OpenUengineRootData():
threading.Thread(target=os.system, args=["xdg-open /data/uengine/data/data"]).start()
# 打开 uengine 用户数据目录
def OpenUengineUserData():
threading.Thread(target=os.system, args=["xdg-open ~/安卓应用文件"]).start()
# 添加/删除 uengine 应用快捷方式
class AddNewUengineDesktopLink():
addTips = '''可以输入app的包名和Activity或通过浏览apk文件来获取包名和Activity
注意如果是要删除只要输入包名即可'''
@ -563,6 +584,7 @@ class AddNewUengineDesktopLink():
activityName = ttk.Combobox(message, width=30)
findApk = ttk.Button(message, text="浏览", command=AddNewUengineDesktopLink.FindApk)
controlFrame = ttk.Frame(message)
testOpen = ttk.Button(controlFrame, text="打开", command=AddNewUengineDesktopLink.TestOpen)
saveButton = ttk.Button(controlFrame, text="写入", command=AddNewUengineDesktopLink.SaveDesktopLink)
delButton = ttk.Button(controlFrame, text="删除", command=AddNewUengineDesktopLink.DelDesktopLink)
@ -586,11 +608,13 @@ class AddNewUengineDesktopLink():
activityName.grid(row=1, column=1)
findApk.grid(row=1, column=2)
controlFrame.grid(row=2, column=0, columnspan=3)
saveButton.grid(row=0, column=0)
delButton.grid(row=0, column=1)
testOpen.grid(row=0, column=0)
saveButton.grid(row=0, column=1)
delButton.grid(row=0, column=2)
message.mainloop()
# 添加快捷方式
def SaveDesktopLink():
if os.path.exists("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get())):
if not messagebox.askokcancel(title="提示", message="文件已存在,确定要覆盖吗?"):
@ -605,6 +629,7 @@ class AddNewUengineDesktopLink():
AddNewUengineDesktopLink.SaveHistory()
messagebox.showinfo(title="提示", message="创建完毕!")
# 删除快捷方式
def DelDesktopLink():
global packageName
if not os.path.exists("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get())):
@ -620,6 +645,7 @@ class AddNewUengineDesktopLink():
traceback.print_exc()
messagebox.showerror(title="错误", message=traceback.format_exc())
# 保存历史记录
def SaveHistory():
findApkNameHistory.append(packageName.get())
findApkActivityHistory.append(activityName.get())
@ -628,10 +654,12 @@ class AddNewUengineDesktopLink():
write_txt(get_home() + "/.config/uengine-runner/FindApkNameHistory.json", str(json.dumps(ListToDictionary(findApkNameHistory)))) # 将历史记录的数组转换为字典并写入
write_txt(get_home() + "/.config/uengine-runner/FindApkActivityHistory.json", str(json.dumps(ListToDictionary(findApkActivityHistory)))) # 将历史记录的数组转换为字典并写入
# 打开测试
def TestOpen():
threading.Thread(target=os.system, args=["/usr/bin/uengine-launch.sh --package={} --component={}".format(packageName.get(), activityName.get())]).start()
AddNewUengineDesktopLink.SaveHistory()
# 浏览文件
def FindApk():
path = filedialog.askopenfilename(title="选择apk", filetypes=[("APK 文件", "*.apk"), ("所有文件", "*.*")], initialdir=json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkName.json"))["path"])
if path == "" or path == ():
@ -643,9 +671,11 @@ class AddNewUengineDesktopLink():
###########################
# 程序信息
###########################
programUrl = "https://gitee.com/gfdgd-xi/uengine-runner"
version = "1.3.3"
goodRunSystem = "Linuxdeepin/UOS"
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")
about = ''' 一个基于 Python3 的 tkinter 制作的 uengine APK 运行器
@ -660,74 +690,17 @@ aapt 版本 {}
程序官网 {}
©2021-{}'''.format(version, goodRunSystem, tk.TkVersion, aaptVersion,programUrl, time.strftime("%Y"))
tips = ''' 新版本Deepin/UOS发布后可以在应用商店安装部分官方已适配的安卓应用对爱好者来说不能自己安装APK软件包始终差点意思本程序可以为Deepin/UOS上的Uengine安卓运行环境安装自定义APK软件包并能发送安装的APK包启动菜单到桌面或系统菜单。
安装APK
点浏览按钮选中需要安装的APK然后点安装按钮
卸载APK
在卸载APK下面的输入框内输入需要卸载的APK包名点卸载按钮如果无法获取包名可以通过浏览APK文件程序自动获取包名进行卸载
保存APK图标
在安装APK下面的输入框浏览或输入APK的路径然后点击保存图标按钮选择保存位置即可
重置删除uengine 数据
点击菜单栏的uengine清空uengine数据输入密码重启即可
注意如果任何安卓一遍打不开多打开几遍应该就可以重新加载uengine配置了
打开Uengine应用列表
打开系统已安装的应用列表安卓界面
提示
1需要你有使用 root 权限的能力
2需要安装 uengine 才能使用
3提取 apk 图标的 apk 路径以安装 apk那栏为准;
4如果想要连接其他手机请使用 1.2.0 以前的版本可以使用 adb 连接
'''
updateThingsString = '''V1.3.3
1添加新版打包方式deepin打包方式;
2支持测试运行/创建/删除uengine图标;
3支持提取安装的apk;
4修改菜单栏布局;
V.1.3.2
1支持uengine数据重置;
2支持修改uengine网络桥接的启动状态;
3支持右键安装/卸载;
4支持启用或禁用uengine;
5修复打包问题不会出现dpkg:警告:卸载spark-uengine-runner时目录/opt/apps/uengine-runner非空因而不会删除该目录的错误;
V1.3.1
1修复打包问题防止部分用户安装出错的问题;
2修复了程序无法提取图标时可以提取默认图标使用;
V1.3.0
1修改了界面布局;
2修复大多数新安装普通用户的路图标及启动菜单文件路径不存在导致安装APK报错的bugs;
3删除少量冗余代码调整代码顺序;
4支持提取apk图标
V1.2.3
1调整部分控件名称
2调整界面布局及界面风格
V1.2.2
1对程序错误的显示更加人性化
'''
tips = "\n".join(information["Tips"])
updateThingsString = "\n".join(information["Update"])
title = "uengine 运行器 {}".format(version)
updateTime = "2021年08月18日"
updateTime = information["Time"]
updateThings = "{} 更新内容:\n{}\n更新时间:{}".format(version, updateThingsString, updateTime, time.strftime("%Y"))
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
iconPath = "{}/icon.png".format(os.path.split(os.path.realpath(__file__))[0])
desktop = "/opt/apps/uengine-runner/UengineAndroidProgramList.desktop"
desktopName = "UengineAndroidProgramList.desktop"
contribute = '''gfdgd xi<3025613752@qq.com>
actionchen<917981399@qq.com>'''
useProgram = '''1、uengine相关软件包基于anbox开发
2Python3
3tkintertkinter.tkttkthemes tkinter.ttk
4aapt
'''
contribute = "\n".join(information["Contribute"])
useProgram = "\n".join(information["Use"])
###########################
# 加载配置
@ -900,6 +873,7 @@ help = tk.Menu(menu, tearoff=0, background="white") # 设置“帮助”菜单
uengineService = tk.Menu(uengine)
uengineInternet = tk.Menu(uengine)
uengineIcon = tk.Menu(uengine)
uengineData = tk.Menu(uengine)
menu.add_cascade(label="程序", menu=programmenu)
menu.add_cascade(label="uengine", menu=uengine)
@ -909,10 +883,11 @@ programmenu.add_command(label="清空软件历史记录", command=CleanProgramHi
programmenu.add_separator() # 设置分界线
programmenu.add_command(label="退出程序", command=window.quit) # 设置“退出程序”
uengine.add_command(label="uengine 应用打包", command=OpenUengineDebBuilder)
uengine.add_cascade(label="uengine 服务", menu=uengineService)
uengine.add_cascade(label="uengine 网络桥接", menu=uengineInternet)
uengine.add_cascade(label="uengine 快捷方式", menu=uengineIcon)
uengine.add_command(label="清空 uengine 数据", command=BackUengineClean)
uengine.add_cascade(label="uengine 数据", menu=uengineData)
help.add_command(label="程序官网", command=OpenProgramURL) # 设置“程序官网”项
help.add_command(label="帮助", command=showhelp) # 设置“关于这个程序”项
@ -934,6 +909,11 @@ uengineIcon.add_command(label="添加/删除指定的 uengine 快捷方式", com
uengineIcon.add_separator()
uengineIcon.add_command(label="清空所有 uengine 快捷方式", command=CleanAllUengineDesktopLink)
uengineData.add_command(label="打开 uengine 根目录", command=OpenUengineRootData)
uengineData.add_command(label="打开 uengine 用户数据目录", command=OpenUengineUserData)
uengineData.add_separator()
uengineData.add_command(label="清空 uengine 数据", command=BackUengineClean)
menu.configure(activebackground="dodgerblue")
help.configure(activebackground="dodgerblue")
uengine.configure(activebackground="dodgerblue")
@ -965,18 +945,18 @@ LabApkPath.grid(row=1, column=0,sticky= tk.W,padx=3)
ComboInstallPath.grid(row=2, column=0,padx=3)
FrmInstall.grid(row=2, column=1,padx=3)
FrmInstall.grid(row=2, column=1,padx=3, rowspan=2)
BtnFindApk.grid(row=0, column=0)
BtnInstall.grid(row=0, column=1)
LabUninstallPath.grid(row=3, column=0,sticky= tk.W,padx=3)
ComboUninstallPath.grid(row=4, column=0,padx=3)
LabUninstallPath.grid(row=4, column=0,sticky= tk.W,padx=3)
ComboUninstallPath.grid(row=5, column=0,padx=3)
FrmUninstall.grid(row=4, column=1,padx=3)
FrmUninstall.grid(row=5, column=1,padx=3)
BtnUninstallApkBrowser.grid(row=0, column=0)
BtnUninstall.grid(row=0, column=1)
BtnShowUengineApp.grid(row=5, column=0,sticky= tk.W,padx=3,pady=2)
BtnShowUengineApp.grid(row=6, column=0,sticky= tk.W,padx=3,pady=2)
Btngeticon.grid(row=1, column=0,sticky= tk.W,padx=3,pady=2)
BtnSaveApk.grid(row=1, column=1,sticky= tk.W,padx=3,pady=2)

View File

@ -1,11 +1,11 @@
Package: com.gitee.uengine.runner.spark
Source: spark-uengine-runner
Version: 1.3.2
Version: 1.4.0
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, adb, python3-pil, python3-setuptools, uengine
Section: utils
Priority: optional
Conflicts: spark-uengine-runner
Conflicts: spark-uengine-runner, spark-uengine-apk-builder
Homepage: [https://gitee.com/gfdgd-xi/uengine-runner, https://github.com/gfdgd-xi/uengine-runner]
Description: uengine runner for deepin and UOS

View File

@ -1,3 +1,10 @@
#!/bin/sh
# 使用 pip 安装所需库
python3 -m pip install --upgrade ttkthemes
# 建立软链接
ln -s /opt/apps/com.gitee.uengine.runner.spark/files/uengine-runner /usr/bin/uengine-runner
ln -s /opt/apps/com.gitee.uengine.runner.spark/files/uengine-apk-builder /usr/bin/uengine-apk-builder
ln -s /opt/apps/com.gitee.uengine.runner.spark/files/uengine-app-uninstall /usr/bin/uengine-app-uninstall
ln -s /opt/apps/com.gitee.uengine.runner.spark/files/uengine-app-install /usr/bin/uengine-app-install
ln -s /opt/apps/com.gitee.uengine.runner.spark/files/uengine-clean /usr/bin/uengine-clean
ln -s /opt/apps/com.gitee.uengine.runner.spark/files/uengine-runner-about /usr/bin/uengine-runner-about

8
new-deb-build/DEBIAN/postrm Executable file
View File

@ -0,0 +1,8 @@
#!/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

View File

@ -0,0 +1,373 @@
Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter
the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination
--------------
5.1. The rights granted under this License will terminate automatically
if You fail to comply with any of its terms. However, if You become
compliant, then the rights granted under this License from a particular
Contributor are reinstated (a) provisionally, unless and until such
Contributor explicitly and finally terminates Your grants, and (b) on an
ongoing basis, if such Contributor fails to notify You of the
non-compliance by some reasonable means prior to 60 days after You have
come back into compliance. Moreover, Your grants from a particular
Contributor are reinstated on an ongoing basis if such Contributor
notifies You of the non-compliance by some reasonable means, this is the
first time You have received notice of non-compliance with this License
from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
************************************************************************
* *
* 7. Limitation of Liability *
* -------------------------- *
* *
* Under no circumstances and under no legal theory, whether tort *
* (including negligence), contract, or otherwise, shall any *
* Contributor, or anyone who distributes Covered Software as *
* permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
8. Litigation
-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
Nothing in this Section shall prevent a party's ability to bring
cross-claims or counter-claims.
9. Miscellaneous
----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
10. Versions of the License
---------------------------
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.

View File

@ -50,13 +50,16 @@ class getsavexml():
#获取所有带前后图片ID的图片路径相同背景或者前景的图片ID但分辨率不一样
backimgs = Findpicpath(resourcelines,backimgid)
foreimgs = Findpicpath(resourcelines,foreimgid)
print(backimgs)
print(foreimgs)
#获取分辨率最高的图片路径
def getmaxsize(imgs):
j = 0
size=(0,0)
zipapk = zipfile.ZipFile(apkFilePath)
imgpath = ""
while j < len(imgs):
print(imgs[j])
img = Image.open(zipapk.open(imgs[j]))
print(imgs[j])
print(img.size)

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -0,0 +1,97 @@
{
"Url": [
"https://gitee.com/gfdgd-xi/uengine-runner"
],
"Version": "1.4.0",
"System": "Linuxdeepin/UOS",
"Tips": [
" 新版本Deepin/UOS发布后可以在应用商店安装部分官方已适配的安卓应用对爱好者来说不能自己安装APK软件包始终差点意思本程序可以为Deepin/UOS上的Uengine安卓运行环境安装自定义APK软件包并能发送安装的APK包启动菜单到桌面或系统菜单。",
"",
"安装APK点浏览按钮选中需要安装的APK然后点安装按钮",
"",
"卸载APK在卸载APK下面的输入框内输入需要卸载的APK包名点卸载按钮如果无法获取包名可以通过浏览APK文件程序自动获取包名进行卸载。",
"",
"保存APK图标在安装APK下面的输入框浏览或输入APK的路径然后点击“保存图标”按钮选择保存位置即可",
"",
"重置删除uengine数据点击菜单栏的“uengine”的“清空uengine数据”输入密码重启即可",
" 注意如果任何安卓一遍打不开多打开几遍应该就可以重新加载uengine配置了",
"",
"打开Uengine应用列表打开系统已安装的应用列表安卓界面",
"",
"提示:",
"1、需要你有使用 root 权限的能力;",
"2、需要安装 uengine 才能使用;",
"3、提取 apk 图标的 apk 路径以“安装 apk”那栏为准;",
"4、如果想要连接其他手机请使用 1.2.0 以前的版本,可以使用 adb 连接。"
],
"Update": [
"V1.4.0",
"※1、添加新版打包方式deepin打包方式;",
"※2、支持测试运行/创建/删除uengine图标;",
"※3、支持提取安装的apk;",
"※4、支持打包deb包;",
"5、修改菜单栏布局;",
"6、支持打开uengine数据目录和用户数据目录;",
"7、程序信息保存到json,非直接写入程序本体;",
"8、更多命令操作;",
"",
"V.1.3.2",
"※1、支持uengine数据重置;",
"※2、支持修改uengine网络桥接的启动状态;",
"※3、支持右键安装/卸载;",
"※4、支持启用或禁用uengine;",
"※5、修复打包问题不会出现“dpkg:警告:卸载spark-uengine-runner时目录/opt/apps/uengine-runner非空因而不会删除该目录”的错误;",
"",
"V1.3.1",
"※1、修复打包问题防止部分用户安装出错的问题;",
"※2、修复了程序无法提取图标时可以提取默认图标使用;",
"",
"V1.3.0",
"※1、修改了界面布局;",
"※2、修复大多数新安装普通用户的路图标及启动菜单文件路径不存在导致安装APK报错的bugs;",
"3、删除少量冗余代码调整代码顺序;",
"4、支持提取apk图标。",
"",
"V1.2.3",
"1、调整部分控件名称",
"2、调整界面布局及界面风格",
"",
"V1.2.2",
"1、对程序错误的显示更加人性化",
"2、对 icon 的获取方式进行了升级;",
"3、增加了注释、删除部分冗余代码。",
"",
"V1.2.1",
"※1、进行了安装方式的修改不使用 adb修复原无法安装和卸载的问题",
"2、进行了部分优化",
"3、进行了功能缩水",
"4、修复 deb 打包错误。",
"",
"V1.2.0",
"1、支持安装自动添加快捷方式、卸载删除快捷方式",
"2、支持使用包名或 APK 文件卸载程序;",
"3、支持查看安装的所有包名",
"4、进行了部分优化",
"",
"V1.1.0",
"暂无数据",
"",
"V1.0.0",
"暂无数据"
],
"Use": [
"1、uengine相关软件包基于anbox开发",
"2、Python3",
"3、tkintertkinter.tk、ttkthemes、tkinter.messagebox、tkinter.simpledialog、tkinter.filedialog 和 tkinter.ttk",
"4、aapt",
"5、dpkg",
"6、tree",
"7、mkdir",
"8、echo",
"9、chmod",
"……"
],
"Time": "2021年08月19日",
"Contribute": ["gfdgd xi<3025613752@qq.com>",
"actionchen<917981399@qq.com>"]
}

View File

@ -0,0 +1,430 @@
#!/usr/bin/env python3
# 使用系统默认的 python3 运行
###########################################################################################
# 作者gfdgd xi
# 版本1.3.3
# 更新时间2021年8月19日
# 感谢anbox、deepin 和 统信
# 基于 Python3 的 tkinter 构建
###########################################################################################
#################
# 引入所需的库
#################
import os
import sys
import json
import shutil
import random
import zipfile
import traceback
import threading
import subprocess
import ttkthemes
import tkinter as tk
import tkinter.ttk as ttk
import tkinter.messagebox as messagebox
import tkinter.filedialog as filedialog
from getxmlimg import getsavexml
def FindApk():
path = filedialog.askopenfilename(title="选择 Apk", filetypes=[("APK 文件", "*.apk"), ("所有文件", "*.*")], initialdir=json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkBuild.json"))["path"])
if path != "" and path != "()":
try:
combobox1.set(path)
write_txt(get_home() + "/.config/uengine-runner/FindApkBuild.json", json.dumps({"path": os.path.dirname(path)})) # 写入配置文件
except:
pass
def BuildDeb():
if combobox1.get() == "":
messagebox.showerror(title="提示", message="信息没有填写完整,无法继续打包 APK")
return
if not os.path.exists(combobox1.get()):
messagebox.showerror(title="提示", message="信息填写错误,无法继续打包 APK")
return
DisabledAndEnbled(True)
threading.Thread(target=BuildApkDeb, args=(combobox1.get(),)).start()
def RunCommandShow(command):
TextboxAddText1("$> {}".format(command))
TextboxAddText1(GetCommandReturn(command))
def BuildApkDeb(apkPath):
tempPath = "/tmp/uengine-apk-builder-{}".format(int(random.randint(0, 1024)))
RunCommandShow("echo '======================================New===================================='")
RunCommandShow("echo '创建目录'")
RunCommandShow("mkdir -pv '{}/DEBIAN'".format(tempPath))
RunCommandShow("mkdir -pv '{}/usr/share/applications'".format(tempPath))
RunCommandShow("mkdir -pv '{}/usr/share/uengine/apk'".format(tempPath))
RunCommandShow("mkdir -pv '{}/usr/share/uengine/icons'".format(tempPath))
RunCommandShow("echo '写入文件,因为写入过程过于复杂,不显示写入命令……'")
apkPackageName = GetApkPackageName(apkPath)
apkPackageVersion = GetApkVersion(apkPath)
apkChineseLabel = GetApkChineseLabel(apkPath)
apkActivityName = GetApkActivityName(apkPath)
iconSavePath = "{}/usr/share/uengine/icons/{}.png".format(tempPath, apkPackageName)
debControl = '''Package: {}
Version: {}
Architecture: all
Maintainer: {}
Depends: deepin-elf-verify (>= 0.0.16.7-1), uengine (>= 1.0.1)
Section: utils
Priority: optional
Description: {}\n'''.format(apkPackageName, apkPackageVersion, apkChineseLabel, apkChineseLabel)
debPostinst = '''#!/bin/sh
APK_DIR="/usr/share/uengine/apk"
APK_NAME="{}.apk"
APK_PATH="$APK_DIR/$APK_NAME"
DESKTOP_FILE="/usr/share/applications/{}.desktop"
ICON_FILE="/usr/share/uengine/icons/{}.png"
if [ -f $APK_PATH ]; then
echo "Installing $APK_NAME"
else
echo "ERROR: $APK_NAME file not found."
exit 1
fi
session_manager=`ps -ef | grep "uengine session-manager" | grep -v grep`
if test -z "$session_manager"; then
echo "ERROR: app install failed(session-manager not start)."
#sudo rm -f $DESKTOP_FILE
#sudo rm -f $ICON_FILE
#sudo rm -f "$APK_PATH"
exit 1
fi
ret=`/usr/bin/uengine-session-launch-helper -- uengine install --apk="$APK_PATH"`
if [ $? -ne 0 ]; then
echo "ERROR: apk install error..."
#sudo rm -f $DESKTOP_FILE
#sudo rm -f $ICON_FILE
#sudo rm -f "$APK_PATH"
exit 1
fi
chkfail=`echo $ret |grep "Failed"`
if test -n "$chkfail" ; then
echo "ERROR: $ret"
#sudo rm -f $DESKTOP_FILE
#sudo rm -f $ICON_FILE
#sudo rm -f "$APK_PATH"
exit 1
fi
sudo rm -f "$APK_PATH"
exit 0'''.format(apkPackageName, apkPackageName, apkPackageName)
debPrerm = '''#!/bin/sh
APP_NAME="{}"
session_manager=`ps -ef | grep "uengine session-manager" | grep -v grep`
if test -z "$session_manager"; then
echo "ERROR: app install failed(session-manager not start)."
exit 1
fi
echo "Uninstalling $APP_NAME"
ret=`/usr/bin/uengine-session-launch-helper -- uengine uninstall --pkg="$APP_NAME"`
if [ $? -ne 0 ]; then
echo "ERROR: app uninstall error..."
exit 1
fi
chkfail=`echo $ret |grep "Failed"`
if test -n "$chkfail" ; then
echo "ERROR: $ret"
exit 1
fi
cat /etc/passwd | awk -F: '$3>=1000' | cut -f 1 -d : | while read line
do
inifile="/home/$line/.config/uengineAppGeometry.ini"
if [ -f $inifile ]; then
sed -i "/$APP_NAME/d" $inifile
fi
done
exit 0'''.format(apkPackageName)
desktopFile = '''[Desktop Entry]
Categories=Other;
Exec=/usr/bin/uengine-launch.sh --action=android.intent.action.MAIN --package={} --component={}
Icon=/usr/share/uengine/icons/{}.png
Terminal=false
Type=Application
GenericName={}
Name={}
'''
#RunCommandShow("echo '{}' > '{}/DEBIAN/control'".format(debControl, tempPath))
RunCommandShow("echo 正在写入文件:'{}/DEBIAN/control'".format(tempPath))
write_txt("{}/DEBIAN/control".format(tempPath), debControl)
RunCommandShow("echo 正在写入文件:'{}/DEBIAN/postinst'".format(tempPath))
write_txt("{}/DEBIAN/postinst".format(tempPath), debPostinst)
RunCommandShow("echo 正在写入文件:'{}/DEBIAN/prerm'".format(tempPath))
write_txt("{}/DEBIAN/prerm".format(tempPath), debPrerm)
RunCommandShow("echo 正在写入文件:'/usr/share/applications/{}.desktop'".format(apkPackageName))
#write_txt("{}/usr/share/applications/{}.desktop".format(tempPath, apkPackageName), desktopFile)
BuildUengineDesktop(apkPackageName, apkActivityName, apkChineseLabel, iconSavePath,
"{}/usr/share/applications/{}.desktop".format(tempPath, apkPackageName))
RunCommandShow("echo '复制文件'")
RunCommandShow("echo '写入 APK 软件图标'")
SaveApkIcon(apkPath, iconSavePath)
RunCommandShow("echo '复制 APK 文件'")
RunCommandShow("cp -rv '{}' '{}/usr/share/uengine/apk/{}.apk'".format(apkPath, tempPath, apkPackageName))
RunCommandShow("echo '正在设置文件权限……'")
RunCommandShow("chmod 0775 -vR '{}/DEBIAN/postinst'".format(tempPath))
RunCommandShow("chmod 0775 -vR '{}/DEBIAN/prerm'".format(tempPath))
RunCommandShow("echo '打包 deb 到桌面……'")
RunCommandShow("dpkg -b '{}' '{}/{}_{}.deb'".format(tempPath, get_desktop_path(),apkPackageName, apkPackageVersion))
RunCommandShow("echo '完成!'")
findApkHistory.append(apkPath)
combobox1['value'] = findApkHistory
write_txt(get_home() + "/.config/uengine-runner/FindApkBuildHistory.json", str(json.dumps(ListToDictionary(findApkHistory)))) # 将历史记录的数组转换为字典并写入
messagebox.showinfo(title="提示", message="打包完成")
DisabledAndEnbled(False)
def DisabledAndEnbled(choose):
userChoose = {True: tk.DISABLED, False: tk.NORMAL}
a = userChoose[choose]
combobox1.configure(state=a)
button2.configure(state=a)
button3.configure(state=a)
# 需引入 subprocess
def GetCommandReturn(cmd):
# cmd 是要获取输出的命令
return subprocess.getoutput(cmd)
# 重启本应用程序
def ReStartProgram():
python = sys.executable
os.execl(python, python, * sys.argv)
# 获取用户主目录
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):
file = open(path, 'w', encoding='UTF-8') # 设置文件对象
file.write(things) # 写入文本
file.close() # 关闭文本对象
def GetApkInformation(apkFilePath):
return GetCommandReturn("aapt dump badging '{}'".format(apkFilePath))
def GetApkActivityName(apkFilePath):
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
def GetApkPackageName(apkFilePath):
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 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
def BuildUengineDesktop(packageName, activityName, showName, iconPath, savePath):
things = '''
[Desktop Entry]
Categories=app;
Encoding=UTF-8
Exec=/usr/bin/uengine-launch.sh --action=android.intent.action.MAIN --package={} --component={}
GenericName={}
Icon={}
MimeType=
Name={}
StartupWMClass={}
Terminal=false
Type=Application
'''.format(packageName, activityName, showName, iconPath, showName, showName)
write_txt(savePath, things)
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
def GetApkIconInApk(apkFilePath):
info = GetApkInformation(apkFilePath)
for line in info.split('\n'):
if "application:" in line:
line = line[line.index("icon='"): -1]
line = line.replace("icon='", "")
if "'" in line:
line = line[0: line.index("'")]
return line
return line
#合并两个函数到一起
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 SaveApkIcon(apkFilePath, iconSavePath):
# zip = zipfile.ZipFile(apkFilePath)
# iconData = zip.read(GetApkIconInApk(apkFilePath))
# with open(iconSavePath, 'w+b') as saveIconFile:
# saveIconFile.write(iconData)
def TextboxAddText1(message):
global textbox1
textbox1.configure(state=tk.NORMAL)
textbox1.insert(tk.END,message + "\n")
textbox1.configure(state=tk.DISABLED)
# 获取用户桌面目录
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 get_home():
return os.path.expanduser('~')
###########################
# 程序信息
###########################
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
information = json.loads(readtxt(programPath + "/information.json"))
version = information["Version"]
title = "uengine APK 应用打包器 {}".format(version)
iconPath = "{}/icon.png".format(os.path.split(os.path.realpath(__file__))[0])
###########################
# 加载配置
###########################
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/FindApkBuildHistory.json"): # 如果没有配置文件
write_txt(get_home() + "/.config/uengine-runner/FindApkBuildHistory.json", json.dumps({})) # 创建配置文件
if not os.path.exists(get_home() + "/.config/uengine-runner/FindApkBuild.json"): # 如果没有配置文件
write_txt(get_home() + "/.config/uengine-runner/FindApkBuild.json", json.dumps({"path": "~"})) # 创建配置文件
###########################
# 设置变量
###########################
findApkHistory = list(json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkBuildHistory.json")).values())
###########################
# 窗口创建
###########################
win = tk.Tk()
window = ttk.Frame(win)
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))
frame2 = ttk.Frame(window)
label1 = ttk.Label(window, text="要打包的 apk 路径:")
combobox1 = ttk.Combobox(window, width=100)
button2 = ttk.Button(window, text="浏览", command=FindApk)
button3 = ttk.Button(frame2, text="打包", command=BuildDeb)
textbox1 = tk.Text(window, width=100)
menu = tk.Menu(window, background="white") # 设置菜单栏
programmenu = tk.Menu(menu, tearoff=0, background="white") # 设置“程序”菜单栏
menu.add_cascade(label="程序", menu=programmenu)
programmenu.add_command(label="退出程序", command=window.quit) # 设置“退出程序”项
# 设置控件
combobox1['value'] = findApkHistory
textbox1.configure(state=tk.DISABLED)
textbox1.config(foreground='white', background='black')
#
win.config(menu=menu) # 显示菜单栏
label1.grid(row=2, column=0)
combobox1.grid(row=2, column=1)
#button1.grid(column=0, row=0)
button2.grid(row=2, column=2)
button3.grid(row=0, column=0)
frame2.grid(row=3, columnspa=3)
textbox1.grid(row=4, columnspa=3)
window.pack()
win.mainloop()

View File

@ -0,0 +1,11 @@
#!/usr/bin/env python3
import os
import sys
if len(sys.argv) > 1:
if sys.argv[1] == "--help":
print("帮助:")
print("uengine-app-install apk路径")
sys.exit(0)
sys.exit(os.system("sudo /usr/bin/uengine-session-launch-helper -- uengine install --apk='{}'".format(sys.argv[1])))
print("命令参数错误")
sys.exit(1)

View File

@ -0,0 +1,11 @@
#!/usr/bin/env python3
import os
import sys
if len(sys.argv) > 1:
if sys.argv[1] == "--help":
print("帮助:")
print("uengine-app-uninstall apk包名")
sys.exit(0)
sys.exit(os.system("sudo /usr/bin/uengine-session-launch-helper -- uengine uninstall --pkg='{}'".format(sys.argv[1])))
print("命令参数错误")
sys.exit(1)

View File

@ -0,0 +1,11 @@
#!/usr/bin/env python3
import os
import sys
if len(sys.argv) > 1:
if sys.argv[1] == "--help":
print("帮助:")
print("输入命令即可清空/重置uengine")
sys.exit(0)
print("参数错误")
sys.exit(1)
sys.exit(os.system("sudo rm -rf /data/uengine"))

View File

@ -11,6 +11,7 @@
#################
# 引入所需的库
#################
from genericpath import exists
import os
import sys
import time
@ -26,6 +27,7 @@ import tkinter as tk
import tkinter.ttk as ttk
import tkinter.messagebox as messagebox
import tkinter.filedialog as filedialog
import tkinter.simpledialog as simpledialog
from getxmlimg import getsavexml
from tkinter.constants import TOP
@ -46,6 +48,7 @@ def UninstallProgram(package: "apk 包名")->"卸载程序":
traceback.print_exc()
messagebox.showerror(title="错误", message=traceback.format_exc())
# 卸载文本框的浏览按钮事件
def BtnFindUninstallApkClk():
path = filedialog.askopenfilename(title="选择 Apk", filetypes=[("APK 文件", "*.apk"), ("所有文件", "*.*")], initialdir=json.loads(readtxt(get_home() + "/.config/uengine-runner/FindUninstallApk.json"))["path"])
if path != "" and path != "()":
@ -55,6 +58,7 @@ def BtnFindUninstallApkClk():
except:
pass
# 卸载按钮事件
def ButtonClick8():
if ComboUninstallPath.get() is "":
messagebox.showerror(title="提示", message="信息没有填写完整,无法继续卸载 APK")
@ -83,6 +87,7 @@ def FindApk()->"浏览窗口":
except:
pass
# 安装按钮事件
def Button3Install():
if ComboInstallPath.get() is "":
messagebox.showerror(title="提示", message="信息没有填写完整,无法继续安装 APK")
@ -139,6 +144,7 @@ def DisabledAndEnbled(choose: "启动或者禁用")->"禁用或启动所有控
BtnUninstallApkBrowser.configure(state=a)
BtnUninstall.configure(state=a)
Btngeticon.configure(state=a)
BtnSaveApk.configure(state=a)
# 需引入 subprocess
# 运行系统命令并获取返回值
@ -146,6 +152,7 @@ def GetCommandReturn(cmd: "命令")->"运行系统命令并获取返回值":
# cmd 是要获取输出的命令
return subprocess.getoutput(cmd)
# 打开所有窗口事件
def Button5Click():
threading.Thread(target=OpenUengineProgramList).start()
@ -334,11 +341,8 @@ def GetApkChineseLabel(apkFilePath)->"获取软件的中文名称":
line = line.replace("'", "")
return line
# 获取图标在包内的路径
#def GetApkIconInApk(apkFilePath)->"获取图标在包内的路径":
#合并两个函数到一起
def SaveApkIcon(apkFilePath, iconSavePath)->"获取 apk 文件的图标":
# 保存apk图标
def SaveApkIcon(apkFilePath, iconSavePath)->"保存 apk 文件的图标":
try:
info = GetApkInformation(apkFilePath)
for line in info.split('\n'):
@ -365,6 +369,7 @@ def saveicon():
print(iconSavePath+"iconpaths")
SaveApkIcon(temppath, iconSavePath)
# 用户自行保存APK
def SaveIconToOtherPath():
apkPath = ComboInstallPath.get()
if apkPath == "":
@ -384,13 +389,7 @@ def SaveIconToOtherPath():
write_txt(get_home() + "/.config/uengine-runner/FindApkHistory.json", str(json.dumps(ListToDictionary(findApkHistory)))) # 将历史记录的数组转换为字典并写入
messagebox.showinfo(title="提示", message="保存成功!")
## 获取 apk 文件的图标(部分程序不支持)
# def SaveApkIcon(apkFilePath, iconSavePath)->"获取 apk 文件的图标(部分程序不支持)":
# zip = zipfile.ZipFile(apkFilePath)
# iconData = zip.read(GetApkIconInApk(apkFilePath))
# with open(iconSavePath, 'w+b') as saveIconFile:
# saveIconFile.write(iconData)
# 清空 uengine 数据
def BackUengineClean()->"清空 uengine 数据":
print("Choose")
if messagebox.askokcancel(title="警告", message="清空后数据将会完全丢失,确定要继续吗?"):
@ -405,32 +404,57 @@ def BackUengineClean()->"清空 uengine 数据":
return
print("Choose False")
def UengineBridgeStart():
# 启用 uengine 网络桥接
def UengineBridgeStart()->"启用 uengine 网络桥接":
DisabledAndEnbled(True)
os.system("pkexec uengine-bridge.sh start")
DisabledAndEnbled(False)
def UengineBridgeStop():
# 关闭 uengine 网络桥接
def UengineBridgeStop()->"关闭 uengine 网络桥接":
DisabledAndEnbled(True)
os.system("pkexec uengine-bridge.sh stop")
DisabledAndEnbled(False)
def UengineBridgeRestart():
# 重启 uengine 网络桥接
def UengineBridgeRestart()->"重启 uengine 网络桥接":
DisabledAndEnbled(True)
os.system("pkexec uengine-bridge.sh restart")
DisabledAndEnbled(False)
def UengineBridgeReload():
# 加载 uengine 网络桥接
def UengineBridgeReload()->"加载 uengine 网络桥接":
DisabledAndEnbled(True)
os.system("pkexec uengine-bridge.sh reload")
DisabledAndEnbled(False)
def UengineBridgeForceReload():
# 强制加载 uengine 网络桥接
def UengineBridgeForceReload()->"强制加载 uengine 网络桥接":
DisabledAndEnbled(True)
os.system("pkexec uengine-bridge.sh force-reload")
DisabledAndEnbled(False)
# 启用 uengine 服务
def StartUengine()->"启用 uengine 服务":
DisabledAndEnbled(True)
os.system("systemctl enable uengine-container uengine-session && systemctl start uengine-container uengine-session")
DisabledAndEnbled(False)
# 关闭 uengine 服务
def StopUengine()->"关闭 uengine 服务":
DisabledAndEnbled(True)
os.system("systemctl disable uengine-container uengine-session")
DisabledAndEnbled(False)
# 重启 uengine 服务
def UengineRestart()->"重启 uengine 服务":
DisabledAndEnbled(True)
os.system("systemctl restart uengine*")
DisabledAndEnbled(False)
# 运行命令的窗口
class InstallWindow():
# 显示窗口
def ShowWindows(command):
global message
global text
@ -454,6 +478,7 @@ class InstallWindow():
threading.Thread(target=InstallWindow.RunCommand, args=[command]).start()
message.mainloop()
# 运行命令并显示
def RunCommand(command):
global message
global text
@ -475,6 +500,7 @@ class InstallWindow():
print("reboot")
os.system("reboot")
# 添加文本
def AddText(things):
global text
text.configure(state=tk.NORMAL)
@ -497,24 +523,161 @@ def get_desktop_path()->"获取用户桌面目录":
get = get.replace("$HOME", get_home()) # 则把其替换为用户目录(~)
return get # 返回目录
# 提取已安装程序的apk
def SaveInstallUengineApp():
while True:
result = simpledialog.askstring(title="输入apk包名", prompt="请输入要获取的apk包名以便进行下一步操作")
if result == "" or result == None:
return
if os.path.exists("/data/uengine/data/data/app/{}-1".format(result)):
break
messagebox.showerror(title="错误", message="路径不存在,请重试!")
path = filedialog.asksaveasfilename(title="保存apk", filetypes=[("APK 文件", "*.apk"), ("所有文件", "*.*")], initialdir=json.loads(readtxt(get_home() + "/.config/uengine-runner/SaveApk.json"))["path"])
if path == "" or path == ():
return
try:
shutil.copy("/data/uengine/data/data/app/{}-1/base.apk".format(result), path)
write_txt(get_home() + "/.config/uengine-runner/SaveApk.json", json.dumps({"path": os.path.dirname(path)}))
messagebox.showinfo(title="提示", message="提取完成!")
except:
traceback.print_exc()
messagebox.showerror(title="错误", message=traceback.format_exc())
# 获取用户主目录
def get_home()->"获取用户主目录":
return os.path.expanduser('~')
def StartUengine():
os.system("systemctl enable uengine-container uengine-session && systemctl start uengine-container uengine-session")
# 删除所有的 uengine 应用快捷方式
def CleanAllUengineDesktopLink():
if messagebox.askokcancel(title="提示", message="你确定要删除所有的 uengine 应用快捷方式吗?"):
try:
shutil.rmtree("{}/.local/share/applications/uengine".format(get_home()))
os.mkdir("{}/.local/share/applications/uengine".format(get_home()))
messagebox.showinfo(title="提示", message="删除完毕!")
except:
traceback.print_exc()
messagebox.showerror(title="错误", message=traceback.format_exc())
def StopUengine():
os.system("systemctl disable uengine-container uengine-session")
# 打开 uengine 应用打包器
def OpenUengineDebBuilder():
threading.Thread(target=os.system, args=[programPath + "/uengine-apk-builder"]).start()
# 打开 uengine 根目录
def OpenUengineRootData():
threading.Thread(target=os.system, args=["xdg-open /data/uengine/data/data"]).start()
# 打开 uengine 用户数据目录
def OpenUengineUserData():
threading.Thread(target=os.system, args=["xdg-open ~/安卓应用文件"]).start()
# 添加/删除 uengine 应用快捷方式
class AddNewUengineDesktopLink():
addTips = '''可以输入app的包名和Activity或通过浏览apk文件来获取包名和Activity
注意:如果是要删除只要输入包名即可'''
def ShowWindow():
global activityName
global packageName
message = tk.Toplevel()
tipsLabel = ttk.Label(message, text=AddNewUengineDesktopLink.addTips)
packageName = ttk.Combobox(message, width=30)
activityName = ttk.Combobox(message, width=30)
findApk = ttk.Button(message, text="浏览", command=AddNewUengineDesktopLink.FindApk)
controlFrame = ttk.Frame(message)
testOpen = ttk.Button(controlFrame, text="打开", command=AddNewUengineDesktopLink.TestOpen)
saveButton = ttk.Button(controlFrame, text="写入", command=AddNewUengineDesktopLink.SaveDesktopLink)
delButton = ttk.Button(controlFrame, text="删除", command=AddNewUengineDesktopLink.DelDesktopLink)
message.title("添加/删除 uengine 图标")
message.resizable(0, 0)
# get screen width and height
screen_width = message.winfo_screenwidth()
screen_height = message.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)
message.geometry("+{}+{}".format(int(x), int(y)))
packageName["value"] = findApkNameHistory
activityName["value"] = findApkActivityHistory
tipsLabel.grid(row=0, column=0, columnspan=3)
packageName.grid(row=1, column=0)
activityName.grid(row=1, column=1)
findApk.grid(row=1, column=2)
controlFrame.grid(row=2, column=0, columnspan=3)
testOpen.grid(row=0, column=0)
saveButton.grid(row=0, column=1)
delButton.grid(row=0, column=2)
message.mainloop()
# 添加快捷方式
def SaveDesktopLink():
if os.path.exists("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get())):
if not messagebox.askokcancel(title="提示", message="文件已存在,确定要覆盖吗?"):
return
global activityName
iconSavePath = "{}/.local/share/icons/hicolor/256x256/apps/{}.png".format(get_home(), packageName.get())
shutil.copy(programPath + "/defult.png", iconSavePath)
BuildUengineDesktop(packageName.get(), activityName, packageName.get(), iconSavePath,
"{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get()))
BuildUengineDesktop(packageName.get(), activityName, packageName.get(), iconSavePath,
"{}/{}.desktop".format(get_desktop_path(), packageName.get()))
AddNewUengineDesktopLink.SaveHistory()
messagebox.showinfo(title="提示", message="创建完毕!")
# 删除快捷方式
def DelDesktopLink():
global packageName
if not os.path.exists("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get())):
messagebox.showerror(title="错误", message="此包名对应的uengine桌面快捷方式不存在")
return
if not messagebox.askyesno(title="提示", message="你确定要删除吗?删除后将无法恢复!"):
return
try:
os.remove("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get()))
AddNewUengineDesktopLink.SaveHistory()
messagebox.showinfo(title="提示", message="已删除")
except:
traceback.print_exc()
messagebox.showerror(title="错误", message=traceback.format_exc())
# 保存历史记录
def SaveHistory():
findApkNameHistory.append(packageName.get())
findApkActivityHistory.append(activityName.get())
packageName['value'] = findApkNameHistory
activityName['value'] = findApkActivityHistory
write_txt(get_home() + "/.config/uengine-runner/FindApkNameHistory.json", str(json.dumps(ListToDictionary(findApkNameHistory)))) # 将历史记录的数组转换为字典并写入
write_txt(get_home() + "/.config/uengine-runner/FindApkActivityHistory.json", str(json.dumps(ListToDictionary(findApkActivityHistory)))) # 将历史记录的数组转换为字典并写入
# 打开测试
def TestOpen():
threading.Thread(target=os.system, args=["/usr/bin/uengine-launch.sh --package={} --component={}".format(packageName.get(), activityName.get())]).start()
AddNewUengineDesktopLink.SaveHistory()
# 浏览文件
def FindApk():
path = filedialog.askopenfilename(title="选择apk", filetypes=[("APK 文件", "*.apk"), ("所有文件", "*.*")], initialdir=json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkName.json"))["path"])
if path == "" or path == ():
return
packageName.set(GetApkPackageName(path))
activityName.set(GetApkActivityName(path))
write_txt(get_home() + "/.config/uengine-runner/FindApkName.json", json.dumps({"path": os.path.dirname(path)})) # 写入配置文件
###########################
# 程序信息
###########################
programUrl = "https://gitee.com/gfdgd-xi/uengine-runner"
version = "1.3.2"
goodRunSystem = "Linuxdeepin/UOS"
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")
about = ''' 一个基于 Python3 的 tkinter 制作的 uengine APK 安装器
about = ''' 一个基于 Python3 的 tkinter 制作的 uengine APK 运行
版本 {}
@ -527,70 +690,17 @@ aapt 版本 {}
程序官网 {}
©2021-{}'''.format(version, goodRunSystem, tk.TkVersion, aaptVersion,programUrl, time.strftime("%Y"))
tips = ''' 新版本Deepin/UOS发布后可以在应用商店安装部分官方已适配的安卓应用对爱好者来说不能自己安装APK软件包始终差点意思本程序可以为Deepin/UOS上的Uengine安卓运行环境安装自定义APK软件包并能发送安装的APK包启动菜单到桌面或系统菜单。
安装APK
点浏览按钮选中需要安装的APK然后点安装按钮
卸载APK
在卸载APK下面的输入框内输入需要卸载的APK包名点卸载按钮如果无法获取包名可以通过浏览APK文件程序自动获取包名进行卸载。
保存APK图标
在安装APK下面的输入框浏览或输入APK的路径然后点击“保存图标”按钮选择保存位置即可
重置删除uengine 数据:
点击菜单栏的“uengine”的“清空uengine数据”输入密码重启即可
注意如果任何安卓一遍打不开多打开几遍应该就可以重新加载uengine配置了
打开Uengine应用列表
打开系统已安装的应用列表(安卓界面)
提示:
1、需要你有使用 root 权限的能力;
2、需要安装 uengine 才能使用;
3、提取 apk 图标的 apk 路径以“安装 apk”那栏为准;
4、如果想要连接其他手机请使用 1.2.0 以前的版本,可以使用 adb 连接。
'''
updateThingsString = '''V.1.3.2
※1、支持uengine数据重置;
※2、支持修改uengine网络桥接的启动状态;
※3、支持右键安装/卸载;
※4、支持启用或禁用uengine;
※5、修复打包问题不会出现“dpkg:警告:卸载spark-uengine-runner时目录/opt/apps/uengine-runner非空因而不会删除该目录”的错误;
V1.3.1
※1、修复打包问题防止部分用户安装出错的问题;
※2、修复了程序无法提取图标时可以提取默认图标使用;
V1.3.0
※1、修改了界面布局;
※2、修复大多数新安装普通用户的路图标及启动菜单文件路径不存在导致安装APK报错的bugs;
3、删除少量冗余代码调整代码顺序;
4、支持提取apk图标。
V1.2.3
1、调整部分控件名称
2、调整界面布局及界面风格
V1.2.2
1、对程序错误的显示更加人性化
2、对icon的获取方式进行了升级
3、增加了注释、删除部分冗余代码。
'''
title = "uengine 安装器 {}".format(version)
updateTime = "2021年08月15日"
tips = "\n".join(information["Tips"])
updateThingsString = "\n".join(information["Update"])
title = "uengine 运行器 {}".format(version)
updateTime = information["Time"]
updateThings = "{} 更新内容:\n{}\n更新时间{}".format(version, updateThingsString, updateTime, time.strftime("%Y"))
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
iconPath = "{}/icon.png".format(os.path.split(os.path.realpath(__file__))[0])
desktop = "/opt/apps/uengine-runner/UengineAndroidProgramList.desktop"
desktopName = "UengineAndroidProgramList.desktop"
contribute = '''gfdgd xi<3025613752@qq.com>
actionchen<917981399@qq.com>'''
useProgram = '''1、uengine相关软件包基于anbox开发
2、Python3
3、tkintertkinter.tk、ttkthemes 和 tkinter.ttk
4、aapt
……'''
contribute = "\n".join(information["Contribute"])
useProgram = "\n".join(information["Use"])
###########################
# 加载配置
@ -601,20 +711,30 @@ 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/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())
fineUninstallApkHistory = list(json.loads(readtxt(get_home() + "/.config/uengine-runner/FindUninstallApkHistory.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
#添加窗口开启关闭开关,防止重复开启
@ -741,7 +861,8 @@ BtnInstall = ttk.Button(FrmInstall, text="安装", command=Button3Install)
BtnShowUengineApp = ttk.Button(window, text="打开 uengine 应用列表", command=Button5Click)
BtnUninstallApkBrowser = ttk.Button(FrmUninstall, text="浏览", command=BtnFindUninstallApkClk)
BtnUninstall = ttk.Button(FrmUninstall, text="卸载", command=ButtonClick8)
Btngeticon = ttk.Button(window, text="保存图标", command=SaveIconToOtherPath)
Btngeticon = ttk.Button(FrmInstall, text="保存图标", command=SaveIconToOtherPath)
BtnSaveApk = ttk.Button(FrmInstall, text="保存apk", command=SaveInstallUengineApp)
# 设置菜单栏
menu = tk.Menu(window, background="white")
@ -749,6 +870,11 @@ programmenu = tk.Menu(menu, tearoff=0, background="white") # 设置“程序”
uengine = tk.Menu(menu, tearoff=0, background="white")
help = tk.Menu(menu, tearoff=0, background="white") # 设置“帮助”菜单栏
uengineService = tk.Menu(uengine)
uengineInternet = tk.Menu(uengine)
uengineIcon = tk.Menu(uengine)
uengineData = tk.Menu(uengine)
menu.add_cascade(label="程序", menu=programmenu)
menu.add_cascade(label="uengine", menu=uengine)
menu.add_cascade(label="关于", menu=help)
@ -757,28 +883,44 @@ programmenu.add_command(label="清空软件历史记录", command=CleanProgramHi
programmenu.add_separator() # 设置分界线
programmenu.add_command(label="退出程序", command=window.quit) # 设置“退出程序”
uengine.add_command(label="发送 uengine 应用列表到桌面", command=SendUengineAndroidListForDesktop)
uengine.add_command(label="发送 uengine 应用列表到启动器", command=SendUengineAndroidListForLauncher)
uengine.add_separator()
uengine.add_command(label="启用 uengine", command=StartUengine)
uengine.add_command(label="禁用 uengine", command=StopUengine)
uengine.add_separator()
uengine.add_command(label="启用 uengine 网络桥接", command=UengineBridgeStart)
uengine.add_command(label="关闭 uengine 网络桥接", command=UengineBridgeStop)
uengine.add_command(label="重启 uengine 网络桥接", command=UengineBridgeRestart)
uengine.add_command(label="加载 uengine 网络桥接", command=UengineBridgeReload)
uengine.add_command(label="强制加载 uengine 网络桥接", command=UengineBridgeForceReload)
uengine.add_separator()
uengine.add_command(label="清空 uengine 数据", command=BackUengineClean)
uengine.add_command(label="uengine 应用打包", command=OpenUengineDebBuilder)
uengine.add_cascade(label="uengine 服务", menu=uengineService)
uengine.add_cascade(label="uengine 网络桥接", menu=uengineInternet)
uengine.add_cascade(label="uengine 快捷方式", menu=uengineIcon)
uengine.add_cascade(label="uengine 数据", menu=uengineData)
help.add_command(label="程序官网", command=OpenProgramURL) # 设置“程序官网”项
help.add_command(label="帮助", command=showhelp) # 设置“关于这个程序”项
uengineService.add_command(label="启用 uengine 服务", command=StartUengine)
uengineService.add_command(label="关闭 uengine 服务", command=StopUengine)
uengineService.add_command(label="重启 uengine 服务", command=UengineRestart)
uengineInternet.add_command(label="启用 uengine 网络桥接", command=UengineBridgeStart)
uengineInternet.add_command(label="关闭 uengine 网络桥接", command=UengineBridgeStop)
uengineInternet.add_command(label="重启 uengine 网络桥接", command=UengineBridgeRestart)
uengineInternet.add_command(label="加载 uengine 网络桥接", command=UengineBridgeReload)
uengineInternet.add_command(label="强制加载 uengine 网络桥接", command=UengineBridgeForceReload)
uengineIcon.add_command(label="发送 uengine 应用列表到桌面", command=SendUengineAndroidListForDesktop)
uengineIcon.add_command(label="发送 uengine 应用列表到启动器", command=SendUengineAndroidListForLauncher)
uengineIcon.add_separator()
uengineIcon.add_command(label="添加/删除指定的 uengine 快捷方式", command=AddNewUengineDesktopLink.ShowWindow)
uengineIcon.add_separator()
uengineIcon.add_command(label="清空所有 uengine 快捷方式", command=CleanAllUengineDesktopLink)
uengineData.add_command(label="打开 uengine 根目录", command=OpenUengineRootData)
uengineData.add_command(label="打开 uengine 用户数据目录", command=OpenUengineUserData)
uengineData.add_separator()
uengineData.add_command(label="清空 uengine 数据", command=BackUengineClean)
menu.configure(activebackground="dodgerblue")
help.configure(activebackground="dodgerblue")
uengine.configure(activebackground="dodgerblue")
programmenu.configure(activebackground="dodgerblue")
uengineService.configure(activebackground="dodgerblue")
uengineInternet.configure(activebackground="dodgerblue")
uengineIcon.configure(activebackground="dodgerblue")
# 设置控件
ComboUninstallPath['value'] = fineUninstallApkHistory
@ -803,20 +945,21 @@ LabApkPath.grid(row=1, column=0,sticky= tk.W,padx=3)
ComboInstallPath.grid(row=2, column=0,padx=3)
FrmInstall.grid(row=2, column=1,padx=3)
FrmInstall.grid(row=2, column=1,padx=3, rowspan=2)
BtnFindApk.grid(row=0, column=0)
BtnInstall.grid(row=0, column=1)
LabUninstallPath.grid(row=3, column=0,sticky= tk.W,padx=3)
ComboUninstallPath.grid(row=4, column=0,padx=3)
LabUninstallPath.grid(row=4, column=0,sticky= tk.W,padx=3)
ComboUninstallPath.grid(row=5, column=0,padx=3)
FrmUninstall.grid(row=4, column=1,padx=3)
FrmUninstall.grid(row=5, column=1,padx=3)
BtnUninstallApkBrowser.grid(row=0, column=0)
BtnUninstall.grid(row=0, column=1)
BtnShowUengineApp.grid(row=5, column=0,sticky= tk.W,padx=3,pady=2)
BtnShowUengineApp.grid(row=6, column=0,sticky= tk.W,padx=3,pady=2)
Btngeticon.grid(row=3, column=1,sticky= tk.W,padx=3,pady=2)
Btngeticon.grid(row=1, column=0,sticky= tk.W,padx=3,pady=2)
BtnSaveApk.grid(row=1, column=1,sticky= tk.W,padx=3,pady=2)
window.pack()

View File

@ -0,0 +1,148 @@
#!/usr/bin/env python3
# 使用系统默认的 python3 运行
###########################################################################################
# 作者gfdgd xi
# 版本1.3.3
# 更新时间2021年8月19日
# 感谢anbox、deepin 和 统信
# 基于 Python3 的 tkinter 构建
###########################################################################################
#################
# 引入所需的库
#################
import os
import time
import json
import ttkthemes
import subprocess
import tkinter as tk
import tkinter.ttk as ttk
# 读取文本文档
def readtxt(path: "路径")->"读取文本文档":
f = open(path, "r") # 设置文件对象
str = f.read() # 获取内容
f.close() # 关闭文本对象
return str # 返回结果
###########################
# 程序信息
###########################
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 = subprocess.getoutput("aapt version")
about = ''' 一个基于 Python3 的 tkinter 制作的 uengine APK 运行器
版本 {}
适用平台 {}
tkinter版本{}
aapt 版本 {}
程序官网 {}
©2021-{}'''.format(version, goodRunSystem, tk.TkVersion, aaptVersion,programUrl, time.strftime("%Y"))
tips = "\n".join(information["Tips"])
updateThingsString = "\n".join(information["Update"])
title = "uengine 运行器 {}".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 = "/opt/apps/uengine-runner/UengineAndroidProgramList.desktop"
desktopName = "UengineAndroidProgramList.desktop"
contribute = "\n".join(information["Contribute"])
useProgram = "\n".join(information["Use"])
# add sub window
#添加窗口开启关闭开关,防止重复开启
windowflag = "close"
def showhelp():
#define window and frame and button label
#
global windowflag
if windowflag == "close":
helpwindow=tk.Tk()
helpwindow.resizable(0, 0)
helpwindow.title("帮助")
# 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))
helpwindow.iconphoto(False, tk.PhotoImage(file=iconPath))
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 ChgDep():
HelpStr.set(useProgram)
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)
BtnZujian = ttk.Button(FrmMenu, text="程序依赖的组件",width=14,command=ChgDep)
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)
BtnZujian.grid(row=2,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)
showhelp()

Binary file not shown.

430
uengine-apk-builder Executable file
View File

@ -0,0 +1,430 @@
#!/usr/bin/env python3
# 使用系统默认的 python3 运行
###########################################################################################
# 作者gfdgd xi
# 版本1.3.3
# 更新时间2021年8月19日
# 感谢anbox、deepin 和 统信
# 基于 Python3 的 tkinter 构建
###########################################################################################
#################
# 引入所需的库
#################
import os
import sys
import json
import shutil
import random
import zipfile
import traceback
import threading
import subprocess
import ttkthemes
import tkinter as tk
import tkinter.ttk as ttk
import tkinter.messagebox as messagebox
import tkinter.filedialog as filedialog
from getxmlimg import getsavexml
def FindApk():
path = filedialog.askopenfilename(title="选择 Apk", filetypes=[("APK 文件", "*.apk"), ("所有文件", "*.*")], initialdir=json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkBuild.json"))["path"])
if path != "" and path != "()":
try:
combobox1.set(path)
write_txt(get_home() + "/.config/uengine-runner/FindApkBuild.json", json.dumps({"path": os.path.dirname(path)})) # 写入配置文件
except:
pass
def BuildDeb():
if combobox1.get() == "":
messagebox.showerror(title="提示", message="信息没有填写完整,无法继续打包 APK")
return
if not os.path.exists(combobox1.get()):
messagebox.showerror(title="提示", message="信息填写错误,无法继续打包 APK")
return
DisabledAndEnbled(True)
threading.Thread(target=BuildApkDeb, args=(combobox1.get(),)).start()
def RunCommandShow(command):
TextboxAddText1("$> {}".format(command))
TextboxAddText1(GetCommandReturn(command))
def BuildApkDeb(apkPath):
tempPath = "/tmp/uengine-apk-builder-{}".format(int(random.randint(0, 1024)))
RunCommandShow("echo '======================================New===================================='")
RunCommandShow("echo '创建目录'")
RunCommandShow("mkdir -pv '{}/DEBIAN'".format(tempPath))
RunCommandShow("mkdir -pv '{}/usr/share/applications'".format(tempPath))
RunCommandShow("mkdir -pv '{}/usr/share/uengine/apk'".format(tempPath))
RunCommandShow("mkdir -pv '{}/usr/share/uengine/icons'".format(tempPath))
RunCommandShow("echo '写入文件,因为写入过程过于复杂,不显示写入命令……'")
apkPackageName = GetApkPackageName(apkPath)
apkPackageVersion = GetApkVersion(apkPath)
apkChineseLabel = GetApkChineseLabel(apkPath)
apkActivityName = GetApkActivityName(apkPath)
iconSavePath = "{}/usr/share/uengine/icons/{}.png".format(tempPath, apkPackageName)
debControl = '''Package: {}
Version: {}
Architecture: all
Maintainer: {}
Depends: deepin-elf-verify (>= 0.0.16.7-1), uengine (>= 1.0.1)
Section: utils
Priority: optional
Description: {}\n'''.format(apkPackageName, apkPackageVersion, apkChineseLabel, apkChineseLabel)
debPostinst = '''#!/bin/sh
APK_DIR="/usr/share/uengine/apk"
APK_NAME="{}.apk"
APK_PATH="$APK_DIR/$APK_NAME"
DESKTOP_FILE="/usr/share/applications/{}.desktop"
ICON_FILE="/usr/share/uengine/icons/{}.png"
if [ -f $APK_PATH ]; then
echo "Installing $APK_NAME"
else
echo "ERROR: $APK_NAME file not found."
exit 1
fi
session_manager=`ps -ef | grep "uengine session-manager" | grep -v grep`
if test -z "$session_manager"; then
echo "ERROR: app install failed(session-manager not start)."
#sudo rm -f $DESKTOP_FILE
#sudo rm -f $ICON_FILE
#sudo rm -f "$APK_PATH"
exit 1
fi
ret=`/usr/bin/uengine-session-launch-helper -- uengine install --apk="$APK_PATH"`
if [ $? -ne 0 ]; then
echo "ERROR: apk install error..."
#sudo rm -f $DESKTOP_FILE
#sudo rm -f $ICON_FILE
#sudo rm -f "$APK_PATH"
exit 1
fi
chkfail=`echo $ret |grep "Failed"`
if test -n "$chkfail" ; then
echo "ERROR: $ret"
#sudo rm -f $DESKTOP_FILE
#sudo rm -f $ICON_FILE
#sudo rm -f "$APK_PATH"
exit 1
fi
sudo rm -f "$APK_PATH"
exit 0'''.format(apkPackageName, apkPackageName, apkPackageName)
debPrerm = '''#!/bin/sh
APP_NAME="{}"
session_manager=`ps -ef | grep "uengine session-manager" | grep -v grep`
if test -z "$session_manager"; then
echo "ERROR: app install failed(session-manager not start)."
exit 1
fi
echo "Uninstalling $APP_NAME"
ret=`/usr/bin/uengine-session-launch-helper -- uengine uninstall --pkg="$APP_NAME"`
if [ $? -ne 0 ]; then
echo "ERROR: app uninstall error..."
exit 1
fi
chkfail=`echo $ret |grep "Failed"`
if test -n "$chkfail" ; then
echo "ERROR: $ret"
exit 1
fi
cat /etc/passwd | awk -F: '$3>=1000' | cut -f 1 -d : | while read line
do
inifile="/home/$line/.config/uengineAppGeometry.ini"
if [ -f $inifile ]; then
sed -i "/$APP_NAME/d" $inifile
fi
done
exit 0'''.format(apkPackageName)
desktopFile = '''[Desktop Entry]
Categories=Other;
Exec=/usr/bin/uengine-launch.sh --action=android.intent.action.MAIN --package={} --component={}
Icon=/usr/share/uengine/icons/{}.png
Terminal=false
Type=Application
GenericName={}
Name={}
'''
#RunCommandShow("echo '{}' > '{}/DEBIAN/control'".format(debControl, tempPath))
RunCommandShow("echo 正在写入文件:'{}/DEBIAN/control'".format(tempPath))
write_txt("{}/DEBIAN/control".format(tempPath), debControl)
RunCommandShow("echo 正在写入文件:'{}/DEBIAN/postinst'".format(tempPath))
write_txt("{}/DEBIAN/postinst".format(tempPath), debPostinst)
RunCommandShow("echo 正在写入文件:'{}/DEBIAN/prerm'".format(tempPath))
write_txt("{}/DEBIAN/prerm".format(tempPath), debPrerm)
RunCommandShow("echo 正在写入文件:'/usr/share/applications/{}.desktop'".format(apkPackageName))
#write_txt("{}/usr/share/applications/{}.desktop".format(tempPath, apkPackageName), desktopFile)
BuildUengineDesktop(apkPackageName, apkActivityName, apkChineseLabel, iconSavePath,
"{}/usr/share/applications/{}.desktop".format(tempPath, apkPackageName))
RunCommandShow("echo '复制文件'")
RunCommandShow("echo '写入 APK 软件图标'")
SaveApkIcon(apkPath, iconSavePath)
RunCommandShow("echo '复制 APK 文件'")
RunCommandShow("cp -rv '{}' '{}/usr/share/uengine/apk/{}.apk'".format(apkPath, tempPath, apkPackageName))
RunCommandShow("echo '正在设置文件权限……'")
RunCommandShow("chmod 0775 -vR '{}/DEBIAN/postinst'".format(tempPath))
RunCommandShow("chmod 0775 -vR '{}/DEBIAN/prerm'".format(tempPath))
RunCommandShow("echo '打包 deb 到桌面……'")
RunCommandShow("dpkg -b '{}' '{}/{}_{}.deb'".format(tempPath, get_desktop_path(),apkPackageName, apkPackageVersion))
RunCommandShow("echo '完成!'")
findApkHistory.append(apkPath)
combobox1['value'] = findApkHistory
write_txt(get_home() + "/.config/uengine-runner/FindApkBuildHistory.json", str(json.dumps(ListToDictionary(findApkHistory)))) # 将历史记录的数组转换为字典并写入
messagebox.showinfo(title="提示", message="打包完成")
DisabledAndEnbled(False)
def DisabledAndEnbled(choose):
userChoose = {True: tk.DISABLED, False: tk.NORMAL}
a = userChoose[choose]
combobox1.configure(state=a)
button2.configure(state=a)
button3.configure(state=a)
# 需引入 subprocess
def GetCommandReturn(cmd):
# cmd 是要获取输出的命令
return subprocess.getoutput(cmd)
# 重启本应用程序
def ReStartProgram():
python = sys.executable
os.execl(python, python, * sys.argv)
# 获取用户主目录
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):
file = open(path, 'w', encoding='UTF-8') # 设置文件对象
file.write(things) # 写入文本
file.close() # 关闭文本对象
def GetApkInformation(apkFilePath):
return GetCommandReturn("aapt dump badging '{}'".format(apkFilePath))
def GetApkActivityName(apkFilePath):
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
def GetApkPackageName(apkFilePath):
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 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
def BuildUengineDesktop(packageName, activityName, showName, iconPath, savePath):
things = '''
[Desktop Entry]
Categories=app;
Encoding=UTF-8
Exec=/usr/bin/uengine-launch.sh --action=android.intent.action.MAIN --package={} --component={}
GenericName={}
Icon={}
MimeType=
Name={}
StartupWMClass={}
Terminal=false
Type=Application
'''.format(packageName, activityName, showName, iconPath, showName, showName)
write_txt(savePath, things)
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
def GetApkIconInApk(apkFilePath):
info = GetApkInformation(apkFilePath)
for line in info.split('\n'):
if "application:" in line:
line = line[line.index("icon='"): -1]
line = line.replace("icon='", "")
if "'" in line:
line = line[0: line.index("'")]
return line
return line
#合并两个函数到一起
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 SaveApkIcon(apkFilePath, iconSavePath):
# zip = zipfile.ZipFile(apkFilePath)
# iconData = zip.read(GetApkIconInApk(apkFilePath))
# with open(iconSavePath, 'w+b') as saveIconFile:
# saveIconFile.write(iconData)
def TextboxAddText1(message):
global textbox1
textbox1.configure(state=tk.NORMAL)
textbox1.insert(tk.END,message + "\n")
textbox1.configure(state=tk.DISABLED)
# 获取用户桌面目录
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 get_home():
return os.path.expanduser('~')
###########################
# 程序信息
###########################
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
information = json.loads(readtxt(programPath + "/information.json"))
version = information["Version"]
title = "uengine APK 应用打包器 {}".format(version)
iconPath = "{}/icon.png".format(os.path.split(os.path.realpath(__file__))[0])
###########################
# 加载配置
###########################
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/FindApkBuildHistory.json"): # 如果没有配置文件
write_txt(get_home() + "/.config/uengine-runner/FindApkBuildHistory.json", json.dumps({})) # 创建配置文件
if not os.path.exists(get_home() + "/.config/uengine-runner/FindApkBuild.json"): # 如果没有配置文件
write_txt(get_home() + "/.config/uengine-runner/FindApkBuild.json", json.dumps({"path": "~"})) # 创建配置文件
###########################
# 设置变量
###########################
findApkHistory = list(json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkBuildHistory.json")).values())
###########################
# 窗口创建
###########################
win = tk.Tk()
window = ttk.Frame(win)
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))
frame2 = ttk.Frame(window)
label1 = ttk.Label(window, text="要打包的 apk 路径:")
combobox1 = ttk.Combobox(window, width=100)
button2 = ttk.Button(window, text="浏览", command=FindApk)
button3 = ttk.Button(frame2, text="打包", command=BuildDeb)
textbox1 = tk.Text(window, width=100)
menu = tk.Menu(window, background="white") # 设置菜单栏
programmenu = tk.Menu(menu, tearoff=0, background="white") # 设置“程序”菜单栏
menu.add_cascade(label="程序", menu=programmenu)
programmenu.add_command(label="退出程序", command=window.quit) # 设置“退出程序”项
# 设置控件
combobox1['value'] = findApkHistory
textbox1.configure(state=tk.DISABLED)
textbox1.config(foreground='white', background='black')
#
win.config(menu=menu) # 显示菜单栏
label1.grid(row=2, column=0)
combobox1.grid(row=2, column=1)
#button1.grid(column=0, row=0)
button2.grid(row=2, column=2)
button3.grid(row=0, column=0)
frame2.grid(row=3, columnspa=3)
textbox1.grid(row=4, columnspa=3)
window.pack()
win.mainloop()

11
uengine-app-install Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env python3
import os
import sys
if len(sys.argv) > 1:
if sys.argv[1] == "--help":
print("帮助:")
print("uengine-app-install apk路径")
sys.exit(0)
sys.exit(os.system("sudo /usr/bin/uengine-session-launch-helper -- uengine install --apk='{}'".format(sys.argv[1])))
print("命令参数错误")
sys.exit(1)

11
uengine-app-uninstall Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env python3
import os
import sys
if len(sys.argv) > 1:
if sys.argv[1] == "--help":
print("帮助:")
print("uengine-app-uninstall apk包名")
sys.exit(0)
sys.exit(os.system("sudo /usr/bin/uengine-session-launch-helper -- uengine uninstall --pkg='{}'".format(sys.argv[1])))
print("命令参数错误")
sys.exit(1)

11
uengine-clean Normal file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env python3
import os
import sys
if len(sys.argv) > 1:
if sys.argv[1] == "--help":
print("帮助:")
print("输入命令即可清空/重置uengine")
sys.exit(0)
print("参数错误")
sys.exit(1)
sys.exit(os.system("sudo rm -rf /data/uengine"))

148
uengine-runner-about Normal file
View File

@ -0,0 +1,148 @@
#!/usr/bin/env python3
# 使用系统默认的 python3 运行
###########################################################################################
# 作者gfdgd xi
# 版本1.3.3
# 更新时间2021年8月19日
# 感谢anbox、deepin 和 统信
# 基于 Python3 的 tkinter 构建
###########################################################################################
#################
# 引入所需的库
#################
import os
import time
import json
import ttkthemes
import subprocess
import tkinter as tk
import tkinter.ttk as ttk
# 读取文本文档
def readtxt(path: "路径")->"读取文本文档":
f = open(path, "r") # 设置文件对象
str = f.read() # 获取内容
f.close() # 关闭文本对象
return str # 返回结果
###########################
# 程序信息
###########################
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 = subprocess.getoutput("aapt version")
about = ''' 一个基于 Python3 的 tkinter 制作的 uengine APK 运行器
版本 {}
适用平台 {}
tkinter版本{}
aapt 版本 {}
程序官网 {}
©2021-{}'''.format(version, goodRunSystem, tk.TkVersion, aaptVersion,programUrl, time.strftime("%Y"))
tips = "\n".join(information["Tips"])
updateThingsString = "\n".join(information["Update"])
title = "uengine 运行器 {}".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 = "/opt/apps/uengine-runner/UengineAndroidProgramList.desktop"
desktopName = "UengineAndroidProgramList.desktop"
contribute = "\n".join(information["Contribute"])
useProgram = "\n".join(information["Use"])
# add sub window
#添加窗口开启关闭开关,防止重复开启
windowflag = "close"
def showhelp():
#define window and frame and button label
#
global windowflag
if windowflag == "close":
helpwindow=tk.Tk()
helpwindow.resizable(0, 0)
helpwindow.title("帮助")
# 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))
helpwindow.iconphoto(False, tk.PhotoImage(file=iconPath))
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 ChgDep():
HelpStr.set(useProgram)
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)
BtnZujian = ttk.Button(FrmMenu, text="程序依赖的组件",width=14,command=ChgDep)
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)
BtnZujian.grid(row=2,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)
showhelp()