初步迁移QT
This commit is contained in:
parent
eb44817201
commit
b34877538a
|
@ -4,7 +4,7 @@
|
||||||
"https://gitee.com/gfdgd-xi/uengine-runner",
|
"https://gitee.com/gfdgd-xi/uengine-runner",
|
||||||
"https://github.com/gfdgd-xi/uengine-runner"
|
"https://github.com/gfdgd-xi/uengine-runner"
|
||||||
],
|
],
|
||||||
"Version": "1.7.0",
|
"Version": "1.8.0",
|
||||||
"System": "Linux(deepin/UOS)",
|
"System": "Linux(deepin/UOS)",
|
||||||
"Tips": [
|
"Tips": [
|
||||||
"更多可见:https://gitee.com/gfdgd-xi/uengine-runner/wikis",
|
"更多可见:https://gitee.com/gfdgd-xi/uengine-runner/wikis",
|
||||||
|
|
154
main.py
154
main.py
|
@ -2,8 +2,8 @@
|
||||||
# 使用系统默认的 python3 运行
|
# 使用系统默认的 python3 运行
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
# 作者:gfdgd xi<3025613752@qq.com>
|
# 作者:gfdgd xi<3025613752@qq.com>
|
||||||
# 版本:1.7.0
|
# 版本:1.8.0
|
||||||
# 更新时间:2022年07月08日(暑假了)
|
# 更新时间:2022年07月23日
|
||||||
# 感谢:anbox、deepin 和 UOS
|
# 感谢:anbox、deepin 和 UOS
|
||||||
# 基于 Python3 的 tkinter 构建
|
# 基于 Python3 的 tkinter 构建
|
||||||
# 更新:gfdgd xi<3025613752@qq.com>、actionchen<917981399@qq.com>、为什么您不喜欢熊出没和阿布呢
|
# 更新:gfdgd xi<3025613752@qq.com>、actionchen<917981399@qq.com>、为什么您不喜欢熊出没和阿布呢
|
||||||
|
@ -32,6 +32,9 @@ import matplotlib.pylab
|
||||||
import matplotlib.font_manager
|
import matplotlib.font_manager
|
||||||
import PIL.Image as Image
|
import PIL.Image as Image
|
||||||
import PIL.ImageTk as ImageTk
|
import PIL.ImageTk as ImageTk
|
||||||
|
import PyQt5.QtGui as QtGui
|
||||||
|
import PyQt5.QtCore as QtCore
|
||||||
|
import PyQt5.QtWidgets as QtWidgets
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
import tkinter.ttk as ttk
|
import tkinter.ttk as ttk
|
||||||
import tkinter.messagebox as messagebox
|
import tkinter.messagebox as messagebox
|
||||||
|
@ -1396,7 +1399,154 @@ if not os.path.exists("/usr/bin/uengine"):
|
||||||
###########################
|
###########################
|
||||||
# 窗口创建
|
# 窗口创建
|
||||||
###########################
|
###########################
|
||||||
|
app = QtWidgets.QApplication(sys.argv)
|
||||||
|
window = QtWidgets.QMainWindow()
|
||||||
|
widget = QtWidgets.QWidget()
|
||||||
|
widgetLayout = QtWidgets.QGridLayout()
|
||||||
|
# 权重
|
||||||
|
size = QtWidgets.QSizePolicy()
|
||||||
|
size.setHorizontalPolicy(0)
|
||||||
|
widgetSize = QtWidgets.QSizePolicy()
|
||||||
|
widgetSize.setVerticalPolicy(0)
|
||||||
|
# 创建控件
|
||||||
|
LabApkPath = QtWidgets.QLabel(langFile[lang]["Main"]["MainWindow"]["LabApkPath"])
|
||||||
|
ComboInstallPath = QtWidgets.QComboBox()
|
||||||
|
FrmInstallWidget = QtWidgets.QWidget()
|
||||||
|
FrmInstall = QtWidgets.QGridLayout()
|
||||||
|
BtnFindApk = QtWidgets.QPushButton(langFile[lang]["Main"]["MainWindow"]["BtnFindApk"])
|
||||||
|
BtnInstall = QtWidgets.QPushButton(langFile[lang]["Main"]["MainWindow"]["BtnInstall"])
|
||||||
|
BtnShowUengineApp = QtWidgets.QPushButton(langFile[lang]["Main"]["MainWindow"]["BtnShowUengineApp"])
|
||||||
|
BtnUninstall = QtWidgets.QPushButton(langFile[lang]["Main"]["MainWindow"]["BtnUninstall"])
|
||||||
|
Btngeticon = QtWidgets.QPushButton(langFile[lang]["Main"]["MainWindow"]["Btngeticon"])
|
||||||
|
BtnSaveApk = QtWidgets.QPushButton(langFile[lang]["Main"]["MainWindow"]["BtnSaveApk"])
|
||||||
|
BtnApkInformation = QtWidgets.QPushButton(langFile[lang]["Main"]["MainWindow"]["BtnApkInformation"])
|
||||||
|
# 设置控件
|
||||||
|
FrmInstallWidget.setLayout(FrmInstall)
|
||||||
|
FrmInstallWidget.setSizePolicy(size)
|
||||||
|
BtnShowUengineApp.setSizePolicy(size)
|
||||||
|
# 布局控件
|
||||||
|
widgetLayout.addWidget(LabApkPath, 0, 0, 1, 2)
|
||||||
|
widgetLayout.addWidget(ComboInstallPath, 1, 0, 1, 2)
|
||||||
|
widgetLayout.addWidget(BtnShowUengineApp, 2, 0, 1, 1)
|
||||||
|
widgetLayout.addWidget(FrmInstallWidget, 0, 2, 3, 1)
|
||||||
|
FrmInstall.addWidget(BtnFindApk, 0, 0, 1, 1)
|
||||||
|
FrmInstall.addWidget(BtnInstall, 0, 1, 1, 1)
|
||||||
|
FrmInstall.addWidget(BtnUninstall, 1, 0, 1, 1)
|
||||||
|
FrmInstall.addWidget(Btngeticon, 1, 1, 1, 1)
|
||||||
|
FrmInstall.addWidget(BtnSaveApk, 2, 0, 1, 1)
|
||||||
|
FrmInstall.addWidget(BtnApkInformation, 2, 1, 1, 1)
|
||||||
|
# 设置菜单栏
|
||||||
|
menu = window.menuBar()
|
||||||
|
programmenu = menu.addMenu(langFile[lang]["Main"]["MainWindow"]["Menu"][0]["Name"])
|
||||||
|
adb = menu.addMenu(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Name"])
|
||||||
|
uengine = menu.addMenu(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Name"])
|
||||||
|
help = menu.addMenu(langFile[lang]["Main"]["MainWindow"]["Menu"][3]["Name"])
|
||||||
|
|
||||||
|
cleanProgramHistory = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][0]["Menu"][0])
|
||||||
|
settingWindow = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][0]["Menu"][2])
|
||||||
|
exitProgram = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][0]["Menu"][1])
|
||||||
|
programmenu.addAction(cleanProgramHistory)
|
||||||
|
programmenu.addAction(settingWindow)
|
||||||
|
programmenu.addSeparator()
|
||||||
|
programmenu.addAction(exitProgram)
|
||||||
|
|
||||||
|
adbUengineConnect = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][0])
|
||||||
|
adbConnectDevice = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][2])
|
||||||
|
adbChangeUengineDisplaySize = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][3])
|
||||||
|
adbAndroidInstallAppList = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][4])
|
||||||
|
adbTop = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][5])
|
||||||
|
adbShell = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][6])
|
||||||
|
adbScrcpyConnectUengine = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][7])
|
||||||
|
adb.addAction(adbUengineConnect)
|
||||||
|
adb.addSeparator()
|
||||||
|
adbServer = adb.addMenu(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][1]["Name"])
|
||||||
|
adb.addAction(adbConnectDevice)
|
||||||
|
adb.addSeparator()
|
||||||
|
adb.addAction(adbChangeUengineDisplaySize)
|
||||||
|
adb.addAction(adbAndroidInstallAppList)
|
||||||
|
adb.addAction(adbTop)
|
||||||
|
adb.addAction(adbShell)
|
||||||
|
adb.addAction(adbScrcpyConnectUengine)
|
||||||
|
adb.addSeparator()
|
||||||
|
uengineUseAdbm = adb.addMenu(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][8]["Name"])
|
||||||
|
adbStartServer = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][1]["Menu"][0])
|
||||||
|
adbStopServer = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][1]["Menu"][1])
|
||||||
|
adbKillAdbProgress = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][1]["Menu"][2])
|
||||||
|
uengineConnectAdb = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][8]["Menu"][0])
|
||||||
|
uengineUseAdb = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][8]["Menu"][1])
|
||||||
|
uengineDoNotUseAdb = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][8]["Menu"][2])
|
||||||
|
|
||||||
|
adbServer.addAction(adbStartServer)
|
||||||
|
adbServer.addAction(adbStopServer)
|
||||||
|
adbServer.addAction(adbKillAdbProgress)
|
||||||
|
|
||||||
|
uengineUseAdbm.addAction(uengineConnectAdb)
|
||||||
|
uengineUseAdbm.addAction(uengineUseAdb)
|
||||||
|
uengineUseAdbm.addSeparator()
|
||||||
|
uengineUseAdbm.addAction(uengineDoNotUseAdb)
|
||||||
|
|
||||||
|
uengineAllowOrDisallowUpdateAndroidApp = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][13])
|
||||||
|
uengineSetHttpProxy = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][15])
|
||||||
|
uengineOpenDebBuilder = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][1])
|
||||||
|
uengineKeyboardToMouse = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][7])
|
||||||
|
uengineCheckCpu = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][8])
|
||||||
|
uengineUbuntuInstall = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][12])
|
||||||
|
uengineDeleteUengineCheck = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][9])
|
||||||
|
uengineReinstall = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][10])
|
||||||
|
uengineUbuntuInstall = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][14])
|
||||||
|
uengine.addAction(uengineAllowOrDisallowUpdateAndroidApp)
|
||||||
|
uengine.addAction(uengineSetHttpProxy)
|
||||||
|
uengine.addAction(uengineOpenDebBuilder)
|
||||||
|
uengine.addAction(uengineKeyboardToMouse)
|
||||||
|
uengine.addAction(uengineCheckCpu)
|
||||||
|
uengine.addAction(uengineUbuntuInstall)
|
||||||
|
uengineService = uengine.addMenu(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][2]["Name"])
|
||||||
|
uengineInternet = uengine.addMenu(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][3]["Name"])
|
||||||
|
uengineIcon = uengine.addMenu(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][4]["Name"])
|
||||||
|
uengine.addMenu(uengineUseAdbm)
|
||||||
|
uengineData = uengine.addMenu(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][6]["Name"])
|
||||||
|
uengine.addAction(uengineDeleteUengineCheck)
|
||||||
|
uengine.addAction(uengineReinstall)
|
||||||
|
uengine.addAction(uengineUbuntuInstall)
|
||||||
|
|
||||||
|
uengineStart = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][2]["Menu"][0])
|
||||||
|
uengineStop = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][2]["Menu"][1])
|
||||||
|
uengineRestart = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][2]["Menu"][2])
|
||||||
|
uengineService.addAction(uengineStart)
|
||||||
|
uengineService.addAction(uengineStop)
|
||||||
|
uengineService.addAction(uengineRestart)
|
||||||
|
|
||||||
|
uengineBridgeStart = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][3]["Menu"][0])
|
||||||
|
uengineBridgeStop = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][3]["Menu"][1])
|
||||||
|
uengineBridgeRestart = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][3]["Menu"][2])
|
||||||
|
uengineBridgeReload = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][3]["Menu"][3])
|
||||||
|
uengineBridgeForceReload = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][3]["Menu"][4])
|
||||||
|
uengineInternet.addAction(uengineBridgeStart)
|
||||||
|
uengineInternet.addAction(uengineBridgeStop)
|
||||||
|
uengineInternet.addAction(uengineReinstall)
|
||||||
|
uengineInternet.addAction(uengineBridgeReload)
|
||||||
|
uengineInternet.addAction(uengineBridgeForceReload)
|
||||||
|
|
||||||
|
uengineSendUengineAndroidListForDesktop = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][4]["Menu"][0])
|
||||||
|
uengineSendUengineAndroidListForLauncher = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][4]["Menu"][1])
|
||||||
|
uengineAddNewUengineDesktopLink = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][4]["Menu"][2])
|
||||||
|
uengineCleanAllUengineDesktopLink = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][4]["Menu"][3])
|
||||||
|
uengineIcon.addAction(uengineSendUengineAndroidListForDesktop)
|
||||||
|
uengineIcon.addAction(uengineSendUengineAndroidListForLauncher)
|
||||||
|
uengineIcon.addSeparator()
|
||||||
|
uengineIcon.addAction(uengineAddNewUengineDesktopLink)
|
||||||
|
uengineIcon.addSeparator()
|
||||||
|
uengineIcon.addAction(uengineCleanAllUengineDesktopLink)
|
||||||
|
|
||||||
|
#uengineData
|
||||||
|
#uengineRoot
|
||||||
|
# 设置窗口
|
||||||
|
widget.setLayout(widgetLayout)
|
||||||
|
window.setCentralWidget(widget)
|
||||||
|
window.setWindowTitle(title)
|
||||||
|
window.show()
|
||||||
|
window.setFixedSize(window.frameSize().width() * 1.5, window.frameSize().height())
|
||||||
|
sys.exit(app.exec_())
|
||||||
|
|
||||||
# 设置窗口
|
# 设置窗口
|
||||||
#style = ttkthemes.ThemedStyle(win)
|
#style = ttkthemes.ThemedStyle(win)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
# 作者:gfdgd xi
|
# 作者:gfdgd xi
|
||||||
# 版本:1.7.0
|
# 版本:1.7.0
|
||||||
# 更新时间:2022年07月08日(暑假了)
|
# 更新时间:2022年07月23日
|
||||||
# 感谢:anbox、deepin 和 统信
|
# 感谢:anbox、deepin 和 统信
|
||||||
# 基于 Python3 的 tkinter 构建
|
# 基于 Python3 的 tkinter 构建
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
@ -19,78 +19,88 @@ import zipfile
|
||||||
import traceback
|
import traceback
|
||||||
import threading
|
import threading
|
||||||
import subprocess
|
import subprocess
|
||||||
import ttkthemes
|
import PyQt5.QtGui as QtGui
|
||||||
import tkinter as tk
|
import PyQt5.QtCore as QtCore
|
||||||
import tkinter.ttk as ttk
|
import PyQt5.QtWidgets as QtWidgets
|
||||||
import tkinter.messagebox as messagebox
|
|
||||||
import tkinter.filedialog as filedialog
|
|
||||||
from getxmlimg import getsavexml
|
from getxmlimg import getsavexml
|
||||||
|
|
||||||
def FindApk():
|
def FindApk():
|
||||||
path = filedialog.askopenfilename(title="选择 Apk", filetypes=[("APK 文件", "*.apk"), ("所有文件", "*.*")], initialdir=json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkBuild.json"))["path"])
|
path = QtWidgets.QFileDialog.getOpenFileName(widget, "选择 APK", json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkBuild.json"))["path"], "APK 可执行文件(*.apk);;所有文件(*.*)")
|
||||||
if path != "" and path != "()":
|
if path != "" and path != "()":
|
||||||
try:
|
try:
|
||||||
combobox1.set(path)
|
combobox1.setEditText(path[0])
|
||||||
write_txt(get_home() + "/.config/uengine-runner/FindApkBuild.json", json.dumps({"path": os.path.dirname(path)})) # 写入配置文件
|
write_txt(get_home() + "/.config/uengine-runner/FindApkBuild.json", json.dumps({"path": os.path.dirname(path[0])})) # 写入配置文件
|
||||||
except:
|
except:
|
||||||
pass
|
traceback.print_exc()
|
||||||
|
QtWidgets.QMessageBox.critical(widget, "错误", traceback.format_exc())
|
||||||
|
|
||||||
|
class QT:
|
||||||
|
run = None
|
||||||
|
|
||||||
def BuildDeb():
|
def BuildDeb():
|
||||||
if combobox1.get() == "":
|
if combobox1.currentText() == "":
|
||||||
messagebox.showerror(title="提示", message="信息没有填写完整,无法继续打包 APK")
|
QtWidgets.QMessageBox.critical(None, "提示", "信息没有填写完整,无法继续打包 APK")
|
||||||
return
|
return
|
||||||
if not os.path.exists(combobox1.get()):
|
if not os.path.exists(combobox1.currentText()):
|
||||||
messagebox.showerror(title="提示", message="信息填写错误,无法继续打包 APK")
|
QtWidgets.QMessageBox.critical(None, "提示", "信息填写错误,无法继续打包 APK")
|
||||||
return
|
return
|
||||||
DisabledAndEnbled(True)
|
DisabledAndEnbled(True)
|
||||||
threading.Thread(target=GetBuildApkDebError, args=(combobox1.get(),)).start()
|
QT.run = BuildApkDeb(combobox1.currentText())
|
||||||
|
QT.run.signal.connect(TextboxAddText1)
|
||||||
|
QT.run.labelChange.connect(ChangeItems)
|
||||||
|
QT.run.tips.connect(TipsMessagebox)
|
||||||
|
QT.run.start()
|
||||||
|
|
||||||
def RunCommandShow(command):
|
class BuildApkDeb(QtCore.QThread):
|
||||||
TextboxAddText1("$> {}".format(command) + "\n")
|
signal = QtCore.pyqtSignal(str)
|
||||||
res = subprocess.Popen([command], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
labelChange = QtCore.pyqtSignal(str)
|
||||||
# 实时读取程序返回
|
tips = QtCore.pyqtSignal(str)
|
||||||
while res.poll() is None:
|
|
||||||
try:
|
def __init__(self, apkPath) -> None:
|
||||||
texts = res.stdout.readline().decode("utf8")
|
self.apkPath = apkPath
|
||||||
except:
|
super().__init__()
|
||||||
texts = ""
|
|
||||||
print(texts, end="")
|
def RunCommandShow(self, command):
|
||||||
TextboxAddText1(texts)
|
if command.replace(" ", "").replace("\n", "") == "":
|
||||||
|
return
|
||||||
|
self.signal.emit("$> {}".format(command))
|
||||||
|
res = subprocess.Popen([command], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
|
# 实时读取程序返回
|
||||||
|
while res.poll() is None:
|
||||||
|
try:
|
||||||
|
texts = res.stdout.readline().decode("utf8")
|
||||||
|
except:
|
||||||
|
texts = ""
|
||||||
|
print(texts, end="")
|
||||||
|
self.signal.emit(texts)
|
||||||
# 已废弃
|
# 已废弃
|
||||||
# TextboxAddText1(GetCommandReturn(command))
|
# TextboxAddText1(GetCommandReturn(command))
|
||||||
|
|
||||||
def GetBuildApkDebError(apkPath):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
BuildApkDeb(apkPath)
|
apkPath = self.apkPath
|
||||||
except:
|
tempPath = "/tmp/uengine-apk-builder-{}".format(int(random.randint(0, 1024)))
|
||||||
traceback.print_exc()
|
self.RunCommandShow("echo '======================================New===================================='")
|
||||||
messagebox.showerror(title="错误", message=traceback.format_exc())
|
self.RunCommandShow("echo '创建目录'")
|
||||||
DisabledAndEnbled(False)
|
self.RunCommandShow("mkdir -pv '{}/DEBIAN'".format(tempPath))
|
||||||
|
self.RunCommandShow("mkdir -pv '{}/usr/share/applications'".format(tempPath))
|
||||||
def BuildApkDeb(apkPath):
|
self.RunCommandShow("mkdir -pv '{}/usr/share/uengine/apk'".format(tempPath))
|
||||||
textbox1.delete("1.0","end")
|
self.RunCommandShow("mkdir -pv '{}/usr/share/uengine/icons'".format(tempPath))
|
||||||
tempPath = "/tmp/uengine-apk-builder-{}".format(int(random.randint(0, 1024)))
|
self.RunCommandShow("echo '写入文件,因为写入过程过于复杂,不显示写入命令……'")
|
||||||
RunCommandShow("echo '======================================New===================================='")
|
apkPackageName = GetApkPackageName(apkPath, False)
|
||||||
RunCommandShow("echo '创建目录'")
|
if check.isChecked():
|
||||||
RunCommandShow("mkdir -pv '{}/DEBIAN'".format(tempPath))
|
apkPackageNameNew = GetApkPackageName(apkPath, True).lower()
|
||||||
RunCommandShow("mkdir -pv '{}/usr/share/applications'".format(tempPath))
|
else:
|
||||||
RunCommandShow("mkdir -pv '{}/usr/share/uengine/apk'".format(tempPath))
|
apkPackageNameNew = GetApkPackageName(apkPath, False).lower()
|
||||||
RunCommandShow("mkdir -pv '{}/usr/share/uengine/icons'".format(tempPath))
|
apkPackageVersion = GetApkVersion(apkPath)
|
||||||
RunCommandShow("echo '写入文件,因为写入过程过于复杂,不显示写入命令……'")
|
if apkPackageVersion[0].upper() == "V":
|
||||||
apkPackageName = GetApkPackageName(apkPath, False)
|
package = list(apkPackageVersion)
|
||||||
if qianZhui.get():
|
package.pop(0)
|
||||||
apkPackageNameNew = GetApkPackageName(apkPath, True).lower()
|
apkPackageVersion = "".join(package)
|
||||||
else:
|
apkChineseLabel = GetApkChineseLabel(apkPath)
|
||||||
apkPackageNameNew = GetApkPackageName(apkPath, False).lower()
|
apkActivityName = GetApkActivityName(apkPath)
|
||||||
apkPackageVersion = GetApkVersion(apkPath)
|
iconSavePath = "{}/usr/share/uengine/icons/{}.png".format(tempPath, apkPackageNameNew)
|
||||||
if apkPackageVersion[0].upper() == "V":
|
debControl = '''Package: {}
|
||||||
package = list(apkPackageVersion)
|
|
||||||
package.pop(0)
|
|
||||||
apkPackageVersion = "".join(package)
|
|
||||||
apkChineseLabel = GetApkChineseLabel(apkPath)
|
|
||||||
apkActivityName = GetApkActivityName(apkPath)
|
|
||||||
iconSavePath = "{}/usr/share/uengine/icons/{}.png".format(tempPath, apkPackageNameNew)
|
|
||||||
debControl = '''Package: {}
|
|
||||||
Version: {}
|
Version: {}
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Maintainer: {}
|
Maintainer: {}
|
||||||
|
@ -98,7 +108,7 @@ Depends: deepin-elf-verify (>= 0.0.16.7-1), uengine (>= 1.0.1)
|
||||||
Section: utils
|
Section: utils
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Description: {}\n'''.format(apkPackageNameNew, apkPackageVersion, apkChineseLabel, apkChineseLabel)
|
Description: {}\n'''.format(apkPackageNameNew, apkPackageVersion, apkChineseLabel, apkChineseLabel)
|
||||||
debPostinst = '''#!/bin/sh
|
debPostinst = '''#!/bin/sh
|
||||||
|
|
||||||
APK_DIR="/usr/share/uengine/apk"
|
APK_DIR="/usr/share/uengine/apk"
|
||||||
APK_NAME="{}"
|
APK_NAME="{}"
|
||||||
|
@ -135,7 +145,7 @@ fi
|
||||||
/usr/bin/uengine-session-launch-helper -- uengine install --apk="$APK_PATH"
|
/usr/bin/uengine-session-launch-helper -- uengine install --apk="$APK_PATH"
|
||||||
|
|
||||||
exit 0'''.format(apkPackageNameNew + ".apk", "/usr/share/applications/{}.desktop".format(apkPackageNameNew))
|
exit 0'''.format(apkPackageNameNew + ".apk", "/usr/share/applications/{}.desktop".format(apkPackageNameNew))
|
||||||
debPrerm = '''#!/bin/sh
|
debPrerm = '''#!/bin/sh
|
||||||
|
|
||||||
APP_NAME="{}"
|
APP_NAME="{}"
|
||||||
DESKTOP_FILE="{}"
|
DESKTOP_FILE="{}"
|
||||||
|
@ -157,7 +167,7 @@ echo "Uninstalling $APP_NAME"
|
||||||
/usr/bin/uengine-session-launch-helper -- uengine uninstall --pkg="$APP_NAME"
|
/usr/bin/uengine-session-launch-helper -- uengine uninstall --pkg="$APP_NAME"
|
||||||
|
|
||||||
exit 0'''.format(apkPackageName, "/usr/share/applications/{}.desktop".format(apkPackageNameNew))
|
exit 0'''.format(apkPackageName, "/usr/share/applications/{}.desktop".format(apkPackageNameNew))
|
||||||
desktopFile = '''[Desktop Entry]
|
desktopFile = '''[Desktop Entry]
|
||||||
Categories=Other;
|
Categories=Other;
|
||||||
Exec=uengine launch --action=android.intent.action.MAIN --package={} --component={}
|
Exec=uengine launch --action=android.intent.action.MAIN --package={} --component={}
|
||||||
Icon=/usr/share/uengine/icons/{}.png
|
Icon=/usr/share/uengine/icons/{}.png
|
||||||
|
@ -166,54 +176,63 @@ Type=Application
|
||||||
GenericName={}
|
GenericName={}
|
||||||
Name={}
|
Name={}
|
||||||
'''
|
'''
|
||||||
#RunCommandShow("echo '{}' > '{}/DEBIAN/control'".format(debControl, tempPath))
|
#self.RunCommandShow("echo '{}' > '{}/DEBIAN/control'".format(debControl, tempPath))
|
||||||
RunCommandShow("echo 正在写入文件:'{}/DEBIAN/control'".format(tempPath))
|
self.RunCommandShow("echo 正在写入文件:'{}/DEBIAN/control'".format(tempPath))
|
||||||
write_txt("{}/DEBIAN/control".format(tempPath), debControl)
|
write_txt("{}/DEBIAN/control".format(tempPath), debControl)
|
||||||
RunCommandShow("echo 正在写入文件:'{}/DEBIAN/postinst'".format(tempPath))
|
self.RunCommandShow("echo 正在写入文件:'{}/DEBIAN/postinst'".format(tempPath))
|
||||||
write_txt("{}/DEBIAN/postinst".format(tempPath), debPostinst)
|
write_txt("{}/DEBIAN/postinst".format(tempPath), debPostinst)
|
||||||
RunCommandShow("echo 正在写入文件:'{}/DEBIAN/prerm'".format(tempPath))
|
self.RunCommandShow("echo 正在写入文件:'{}/DEBIAN/prerm'".format(tempPath))
|
||||||
write_txt("{}/DEBIAN/prerm".format(tempPath), debPrerm)
|
write_txt("{}/DEBIAN/prerm".format(tempPath), debPrerm)
|
||||||
RunCommandShow("echo 正在写入文件:'/usr/share/applications/{}.desktop'".format(apkPackageNameNew))
|
self.RunCommandShow("echo 正在写入文件:'/usr/share/applications/{}.desktop'".format(apkPackageNameNew))
|
||||||
#write_txt("{}/usr/share/applications/{}.desktop".format(tempPath, apkPackageNameNew), desktopFile)
|
#write_txt("{}/usr/share/applications/{}.desktop".format(tempPath, apkPackageNameNew), desktopFile)
|
||||||
BuildUengineDesktop(apkPackageName, apkActivityName, apkChineseLabel, "/usr/share/uengine/icons/{}.png".format(apkPackageNameNew),
|
BuildUengineDesktop(apkPackageName, apkActivityName, apkChineseLabel, "/usr/share/uengine/icons/{}.png".format(apkPackageNameNew),
|
||||||
"{}/usr/share/applications/{}.desktop".format(tempPath, apkPackageNameNew))
|
"{}/usr/share/applications/{}.desktop".format(tempPath, apkPackageNameNew))
|
||||||
RunCommandShow("echo '复制文件'")
|
self.RunCommandShow("echo '复制文件'")
|
||||||
RunCommandShow("echo '写入 APK 软件图标'")
|
self.RunCommandShow("echo '写入 APK 软件图标'")
|
||||||
SaveApkIcon(apkPath, iconSavePath)
|
SaveApkIcon(apkPath, iconSavePath)
|
||||||
RunCommandShow("echo '复制 APK 文件'")
|
self.RunCommandShow("echo '复制 APK 文件'")
|
||||||
RunCommandShow("cp -rv '{}' '{}/usr/share/uengine/apk/{}.apk'".format(apkPath, tempPath, apkPackageNameNew))
|
self.RunCommandShow("cp -rv '{}' '{}/usr/share/uengine/apk/{}.apk'".format(apkPath, tempPath, apkPackageNameNew))
|
||||||
RunCommandShow("echo '正在设置文件权限……'")
|
self.RunCommandShow("echo '正在设置文件权限……'")
|
||||||
RunCommandShow("chmod 0775 -vR '{}/DEBIAN/postinst'".format(tempPath))
|
self.RunCommandShow("chmod 0775 -vR '{}/DEBIAN/postinst'".format(tempPath))
|
||||||
RunCommandShow("chmod 0775 -vR '{}/DEBIAN/prerm'".format(tempPath))
|
self.RunCommandShow("chmod 0775 -vR '{}/DEBIAN/prerm'".format(tempPath))
|
||||||
RunCommandShow("echo '打包 deb 到桌面……'")
|
self.RunCommandShow("echo '打包 deb 到桌面……'")
|
||||||
RunCommandShow("dpkg -b '{}' '{}/{}_{}.deb'".format(tempPath, get_desktop_path(),apkPackageNameNew, apkPackageVersion))
|
self.RunCommandShow("dpkg -b '{}' '{}/{}_{}.deb'".format(tempPath, get_desktop_path(),apkPackageNameNew, apkPackageVersion))
|
||||||
RunCommandShow("echo '正在删除临时目录……'")
|
self.RunCommandShow("echo '正在删除临时目录……'")
|
||||||
RunCommandShow("rm -rfv '{}'".format(tempPath))
|
self.RunCommandShow("rm -rfv '{}'".format(tempPath))
|
||||||
RunCommandShow("echo '完成!'")
|
self.RunCommandShow("echo '完成!'")
|
||||||
findApkHistory.append(apkPath)
|
findApkHistory.append(apkPath)
|
||||||
combobox1['value'] = findApkHistory
|
self.labelChange.emit("")
|
||||||
write_txt(get_home() + "/.config/uengine-runner/FindApkBuildHistory.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)
|
||||||
DisabledAndEnbled(False)
|
self.tips.emit("打包完成")
|
||||||
|
|
||||||
|
except:
|
||||||
|
DisabledAndEnbled(False)
|
||||||
|
traceback.print_exc()
|
||||||
|
QtWidgets.QMessageBox.critical(widget, "错误", traceback.format_exc())
|
||||||
|
|
||||||
|
def TipsMessagebox(tips):
|
||||||
|
QtWidgets.QMessageBox.information(widget, "提示", tips)
|
||||||
|
|
||||||
|
def ChangeItems(self):
|
||||||
|
combobox1.clear()
|
||||||
|
combobox1.addItems(findApkHistory)
|
||||||
|
#combobox1.setEditText("")
|
||||||
|
|
||||||
def DisabledAndEnbled(choose):
|
def DisabledAndEnbled(choose):
|
||||||
userChoose = {True: tk.DISABLED, False: tk.NORMAL}
|
combobox1.setDisabled(choose)
|
||||||
a = userChoose[choose]
|
check.setDisabled(choose)
|
||||||
combobox1.configure(state=a)
|
button2.setDisabled(choose)
|
||||||
check.configure(state=a)
|
button3.setDisabled(choose)
|
||||||
button2.configure(state=a)
|
|
||||||
button3.configure(state=a)
|
|
||||||
|
|
||||||
# 需引入 subprocess
|
|
||||||
def GetCommandReturn(cmd):
|
|
||||||
# cmd 是要获取输出的命令
|
|
||||||
return subprocess.getoutput(cmd)
|
|
||||||
|
|
||||||
# 重启本应用程序
|
# 重启本应用程序
|
||||||
def ReStartProgram():
|
def ReStartProgram():
|
||||||
python = sys.executable
|
python = sys.executable
|
||||||
os.execl(python, python, * sys.argv)
|
os.execl(python, python, * sys.argv)
|
||||||
|
|
||||||
|
def GetCommandReturn(command):
|
||||||
|
return subprocess.getoutput(command)
|
||||||
|
|
||||||
# 获取用户主目录
|
# 获取用户主目录
|
||||||
def get_home():
|
def get_home():
|
||||||
return os.path.expanduser('~')
|
return os.path.expanduser('~')
|
||||||
|
@ -354,9 +373,7 @@ def SaveApkIcon(apkFilePath, iconSavePath)->"获取 apk 文件的图标":
|
||||||
|
|
||||||
def TextboxAddText1(message):
|
def TextboxAddText1(message):
|
||||||
global textbox1
|
global textbox1
|
||||||
textbox1.configure(state=tk.NORMAL)
|
textbox1.append(message)
|
||||||
textbox1.insert(tk.END,message)
|
|
||||||
textbox1.configure(state=tk.DISABLED)
|
|
||||||
|
|
||||||
# 获取用户桌面目录
|
# 获取用户桌面目录
|
||||||
def get_desktop_path():
|
def get_desktop_path():
|
||||||
|
@ -388,7 +405,7 @@ if not lang in langFile.keys():
|
||||||
information = json.loads(readtxt(programPath + "/information.json"))
|
information = json.loads(readtxt(programPath + "/information.json"))
|
||||||
version = information["Version"]
|
version = information["Version"]
|
||||||
title = "{} {}".format(langFile[lang]["Uengine Apk Builder"]["Title"], version)
|
title = "{} {}".format(langFile[lang]["Uengine Apk Builder"]["Title"], version)
|
||||||
iconPath = "{}/builer.png".format(os.path.split(os.path.realpath(__file__))[0])
|
iconPath = "{}/builer.svg".format(os.path.split(os.path.realpath(__file__))[0])
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
# 加载配置
|
# 加载配置
|
||||||
|
@ -408,6 +425,53 @@ findApkHistory = list(json.loads(readtxt(get_home() + "/.config/uengine-runner/F
|
||||||
###########################
|
###########################
|
||||||
# 窗口创建
|
# 窗口创建
|
||||||
###########################
|
###########################
|
||||||
|
app = QtWidgets.QApplication(sys.argv)
|
||||||
|
# 权重
|
||||||
|
size = QtWidgets.QSizePolicy()
|
||||||
|
size.setHorizontalPolicy(0)
|
||||||
|
widgetSize = QtWidgets.QSizePolicy()
|
||||||
|
widgetSize.setVerticalPolicy(0)
|
||||||
|
#
|
||||||
|
window = QtWidgets.QMainWindow()
|
||||||
|
widget = QtWidgets.QWidget()
|
||||||
|
widgetLayout = QtWidgets.QGridLayout()
|
||||||
|
combobox1 = QtWidgets.QComboBox()
|
||||||
|
label1 = QtWidgets.QLabel(langFile[lang]["Uengine Apk Builder"]["label1"])
|
||||||
|
button2 = QtWidgets.QPushButton(langFile[lang]["Uengine Apk Builder"]["button2"])
|
||||||
|
button3 = QtWidgets.QPushButton(langFile[lang]["Uengine Apk Builder"]["button3"])
|
||||||
|
textbox1 = QtWidgets.QTextBrowser()
|
||||||
|
frame2 = QtWidgets.QHBoxLayout()
|
||||||
|
check = QtWidgets.QCheckBox(langFile[lang]["Uengine Apk Builder"]["check"])
|
||||||
|
label1.setSizePolicy(size)
|
||||||
|
button2.setSizePolicy(size)
|
||||||
|
check.setSizePolicy(size)
|
||||||
|
button3.setSizePolicy(size)
|
||||||
|
combobox1.setEditable(True)
|
||||||
|
combobox1.addItems(findApkHistory)
|
||||||
|
combobox1.setEditText("")
|
||||||
|
button2.clicked.connect(FindApk)
|
||||||
|
button3.clicked.connect(BuildDeb)
|
||||||
|
widgetLayout.addWidget(label1, 0, 0, 1, 1)
|
||||||
|
widgetLayout.addWidget(combobox1, 0, 1, 1, 1)
|
||||||
|
widgetLayout.addWidget(button2, 0, 2, 1, 1)
|
||||||
|
widgetLayout.addLayout(frame2, 1, 0, 1, 3)
|
||||||
|
widgetLayout.addWidget(textbox1, 2, 0, 1, 3)
|
||||||
|
# 菜单栏
|
||||||
|
menu = window.menuBar()
|
||||||
|
programmenu = menu.addMenu(langFile[lang]["Uengine Apk Builder"]["Menu"][0]["Name"])
|
||||||
|
exitProgram = QtWidgets.QAction(langFile[lang]["Uengine Apk Builder"]["Menu"][0]["Menu"][0])
|
||||||
|
exitProgram.triggered.connect(window.close)
|
||||||
|
programmenu.addAction(exitProgram)
|
||||||
|
#
|
||||||
|
frame2.addWidget(check)
|
||||||
|
frame2.addWidget(button3)
|
||||||
|
widget.setLayout(widgetLayout)
|
||||||
|
window.setWindowTitle(title)
|
||||||
|
window.setCentralWidget(widget)
|
||||||
|
window.setWindowIcon(QtGui.QIcon(iconPath))
|
||||||
|
window.resize(window.frameSize().width() * 1.3, window.frameSize().height() * 1.1)
|
||||||
|
window.show()
|
||||||
|
sys.exit(app.exec_())
|
||||||
# 读取主题
|
# 读取主题
|
||||||
try:
|
try:
|
||||||
theme = not ("dark" in readtxt(get_home() + "/.gtkrc-2.0") and "gtk-theme-name=" in readtxt(get_home() + "/.gtkrc-2.0"))
|
theme = not ("dark" in readtxt(get_home() + "/.gtkrc-2.0") and "gtk-theme-name=" in readtxt(get_home() + "/.gtkrc-2.0"))
|
||||||
|
|
Loading…
Reference in New Issue