From 385348a7b9daf9793d80a2c9a39b953304d0e86a Mon Sep 17 00:00:00 2001 From: gfdgd_xi <3025613752@qq.com> Date: Mon, 29 Jul 2024 09:09:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8C=85=E5=99=A8=E6=94=AF=E6=8C=81im?= =?UTF-8?q?port?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deepin-wine-easy-packager.py | 164 +++++++++++++++++++---------------- deepin-wine-packager.py | 17 ++-- test.py | 8 +- 3 files changed, 105 insertions(+), 84 deletions(-) diff --git a/deepin-wine-easy-packager.py b/deepin-wine-easy-packager.py index 36f2118..c099517 100755 --- a/deepin-wine-easy-packager.py +++ b/deepin-wine-easy-packager.py @@ -19,6 +19,8 @@ import PyQt5.QtCore as QtCore import PyQt5.QtWidgets as QtWidgets from DefaultSetting import * +import globalenv + def ShowText(text: str): if text.replace(" ", "").replace("\n", "") == "": return @@ -669,82 +671,94 @@ def BrowserExe(): exePath.setText(filePath[0]) chooseWine = "" -if __name__ == "__main__": - programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string - iconPath = "{}/deepin-wine-runner.svg".format(programPath) - information = json.loads(ReadTxt(f"{programPath}/information.json")) - iconListUnBuild = json.loads(ReadTxt(f"{programPath}/IconList.json"))[0] - iconList = json.loads(ReadTxt(f"{programPath}/IconList.json"))[1] - for i in iconListUnBuild: - iconList.append(i) + +programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string +iconPath = "{}/deepin-wine-runner.svg".format(programPath) +information = json.loads(ReadTxt(f"{programPath}/information.json")) +iconListUnBuild = json.loads(ReadTxt(f"{programPath}/IconList.json"))[0] +iconList = json.loads(ReadTxt(f"{programPath}/IconList.json"))[1] +for i in iconListUnBuild: + iconList.append(i) +if (__name__ == "__main__"): app = QtWidgets.QApplication(sys.argv) - version = information["Version"] - window = QtWidgets.QMainWindow() - widget = QtWidgets.QWidget() - layout = QtWidgets.QGridLayout() - exePath = QtWidgets.QLineEdit() - wineChooser = QtWidgets.QComboBox() - browserExeButton = QtWidgets.QPushButton("浏览……") - logText = QtWidgets.QTextBrowser() - logText.setStyleSheet(""" - background-color: black; - color: white; - """) - wineChooserList = [ - "使用 Deepin Wine8 Stable 打包应用", - "使用 Spark Wine9 wow 打包应用", - "使用 Spark Wine9 打包应用", - "使用 Spark Wine8 打包应用", - "使用 Spark Wine7 Devel 打包应用", - "使用 Deepin Wine6 Stable 打包应用", - "使用 Deepin Wine5 Stable 打包应用", - "使用 Deepin Wine5 打包应用", - "使用 Deepin Wine2 打包应用", - "使用 Spark Wine 打包应用" - ] - wineChooserIndex = 2 - wineList = ["deepin-wine8-stable", "spark-wine9-wow", "spark-wine9", "spark-wine8", "spark-wine7-devel", "deepin-wine6-stable", "deepin-wine6-vannila", "spark-wine8-wow", "deepin-wine5-stable", "deepin-wine5", "deepin-wine", "spark-wine"] - for i in range(len(wineList)): - if not os.system(f"which '{wineList[i]}'"): - wineChooserIndex = i - break - chooseWine = wineList[wineChooserIndex] - wineChooserList[wineChooserIndex] = f"{wineChooserList[wineChooserIndex]}(推荐,如无特殊需求不建议更换)" - wineChooser.addItems(wineChooserList) - wineChooser.setCurrentIndex(wineChooserIndex) - controlLayout = QtWidgets.QHBoxLayout() - buildButton = QtWidgets.QPushButton("现在打包……") - installCmpleteButton = QtWidgets.QPushButton("安装程序执行完成") - helpButton = QtWidgets.QPushButton("帮助") - installUosPackingTool = QtWidgets.QPushButton("安装维护工具箱(可以安装测试 deb)") - browserExeButton.clicked.connect(BrowserExe) - buildButton.clicked.connect(RunBuildThread) - installCmpleteButton.clicked.connect(PressCompleteDownload) - helpButton.clicked.connect(ReadMe) - def InstallUosPackingTool(): - if os.system("which spark-store"): - QtWidgets.QMessageBox.critical(window, "提示", "未安装星火应用商店,无法继续\n星火应用商店官网:https://spark-app.store/") - return 0 - threading.Thread(target=os.system, args=["spark-store spk://store/tools/uos-packaging-tools"]).start() - installUosPackingTool.clicked.connect(InstallUosPackingTool) - installCmpleteButton.setDisabled(True) - controlLayout.addWidget(buildButton) - controlLayout.addWidget(installCmpleteButton) - controlLayout.addWidget(helpButton) - controlLayout.addWidget(installUosPackingTool) - layout.addWidget(QtWidgets.QLabel("选择 EXE:"), 0, 0) - layout.addWidget(exePath, 0, 1) - layout.addWidget(browserExeButton, 0, 2) - layout.addWidget(wineChooser, 1, 1) - layout.addLayout(controlLayout, 2, 1) - layout.addWidget(logText, 3, 0, 1, 3) - widget.setLayout(layout) - window.setCentralWidget(widget) - window.setWindowTitle(f"Wine 运行器 {version}——简易打包器") - try: - exePath.setText(sys.argv[1]) - except: - pass +else: + app = globalenv.get_value("app") +version = information["Version"] +window = QtWidgets.QMainWindow() +widget = QtWidgets.QWidget() +layout = QtWidgets.QGridLayout() +exePath = QtWidgets.QLineEdit() +wineChooser = QtWidgets.QComboBox() +browserExeButton = QtWidgets.QPushButton("浏览……") +logText = QtWidgets.QTextBrowser() +logText.setStyleSheet(""" + background-color: black; + color: white; +""") +wineChooserList = [ + "使用 Deepin Wine8 Stable 打包应用", + "使用 Spark Wine9 wow 打包应用", + "使用 Spark Wine9 打包应用", + "使用 Spark Wine8 打包应用", + "使用 Spark Wine7 Devel 打包应用", + "使用 Deepin Wine6 Stable 打包应用", + "使用 Deepin Wine5 Stable 打包应用", + "使用 Deepin Wine5 打包应用", + "使用 Deepin Wine2 打包应用", + "使用 Spark Wine 打包应用" +] +wineChooserIndex = 2 +wineList = ["deepin-wine8-stable", "spark-wine9-wow", "spark-wine9", "spark-wine8", "spark-wine7-devel", "deepin-wine6-stable", "deepin-wine6-vannila", "spark-wine8-wow", "deepin-wine5-stable", "deepin-wine5", "deepin-wine", "spark-wine"] +for i in range(len(wineList)): + if not os.system(f"which '{wineList[i]}'"): + wineChooserIndex = i + break +chooseWine = wineList[wineChooserIndex] +wineChooserList[wineChooserIndex] = f"{wineChooserList[wineChooserIndex]}(推荐,如无特殊需求不建议更换)" +wineChooser.addItems(wineChooserList) +wineChooser.setCurrentIndex(wineChooserIndex) +controlLayout = QtWidgets.QHBoxLayout() +buildButton = QtWidgets.QPushButton("现在打包……") +installCmpleteButton = QtWidgets.QPushButton("安装程序执行完成") +helpButton = QtWidgets.QPushButton("帮助") +installUosPackingTool = QtWidgets.QPushButton("安装维护工具箱(可以安装测试 deb)") +browserExeButton.clicked.connect(BrowserExe) +buildButton.clicked.connect(RunBuildThread) +installCmpleteButton.clicked.connect(PressCompleteDownload) +helpButton.clicked.connect(ReadMe) +def InstallUosPackingTool(): + if os.system("which spark-store"): + QtWidgets.QMessageBox.critical(window, "提示", "未安装星火应用商店,无法继续\n星火应用商店官网:https://spark-app.store/") + return 0 + threading.Thread(target=os.system, args=["spark-store spk://store/tools/uos-packaging-tools"]).start() +installUosPackingTool.clicked.connect(InstallUosPackingTool) +installCmpleteButton.setDisabled(True) +controlLayout.addWidget(buildButton) +controlLayout.addWidget(installCmpleteButton) +controlLayout.addWidget(helpButton) +controlLayout.addWidget(installUosPackingTool) +layout.addWidget(QtWidgets.QLabel("选择 EXE:"), 0, 0) +layout.addWidget(exePath, 0, 1) +layout.addWidget(browserExeButton, 0, 2) +layout.addWidget(wineChooser, 1, 1) +layout.addLayout(controlLayout, 2, 1) +layout.addWidget(logText, 3, 0, 1, 3) +widget.setLayout(layout) +window.setCentralWidget(widget) +window.setWindowTitle(f"Wine 运行器 {version}——简易打包器") +try: + exePath.setText(sys.argv[1]) +except: + pass +if (__name__ != "__main__"): + # 设置滚动条 + areaScroll = QtWidgets.QScrollArea(window) + areaScroll.setWidgetResizable(True) + areaScroll.setWidget(widget) + areaScroll.setFrameShape(QtWidgets.QFrame.NoFrame) + window.setCentralWidget(areaScroll) + +if (__name__ == "__main__"): window.resize(int(window.frameGeometry().width() * 1.2), int(window.frameGeometry().height() * 1.1)) window.show() # 设置字体 diff --git a/deepin-wine-packager.py b/deepin-wine-packager.py index f57690c..2ee8c8a 100755 --- a/deepin-wine-packager.py +++ b/deepin-wine-packager.py @@ -27,6 +27,7 @@ import PyQt5.QtWidgets as QtWidgets from trans import * from DefaultSetting import * from Model import * +import globalenv TMPDIR = os.getenv("TMPDIR") if (TMPDIR == None): @@ -2366,7 +2367,10 @@ tips = transla.transe("U", """提示: # 窗口创建 ############### -app = QtWidgets.QApplication(sys.argv) +if (__name__ == "__main__"): + app = QtWidgets.QApplication(sys.argv) +else: + app = globalenv.get_value("app") window = QtWidgets.QMainWindow() widget = QtWidgets.QWidget() @@ -2703,7 +2707,8 @@ SetFont(app) window.setCentralWidget(widget) # 判断是否为小屏幕,是则设置滚动条并全屏 if (window.frameGeometry().width() > app.primaryScreen().availableGeometry().size().width() * 0.8 or - window.frameGeometry().height() > app.primaryScreen().availableGeometry().size().height() * 0.9): + window.frameGeometry().height() > app.primaryScreen().availableGeometry().size().height() * 0.9 or + __name__ != "__main__"): # 设置滚动条 areaScroll = QtWidgets.QScrollArea(window) areaScroll.setWidgetResizable(True) @@ -2711,8 +2716,8 @@ if (window.frameGeometry().width() > app.primaryScreen().availableGeometry().siz areaScroll.setFrameShape(QtWidgets.QFrame.NoFrame) window.setCentralWidget(areaScroll) window.showMaximized() # 设置全屏 -window.show() -window.show() -sys.exit(app.exec_()) -# Flag:解包只读control和解包全部读取 +if (__name__ == "__main__"): + window.show() + sys.exit(app.exec_()) + # Flag:解包只读control和解包全部读取 diff --git a/test.py b/test.py index 0da020e..5a3be1b 100644 --- a/test.py +++ b/test.py @@ -5,8 +5,10 @@ app = QtWidgets.QApplication(sys.argv) window = QtWidgets.QMainWindow() globalenv._init() globalenv.set_value("app", app) - -import mainwindow -window.setCentralWidget(mainwindow.window) +#import deepin_wine_packager +#modules = __import__("deepin-wine-packager") +modules = __import__("deepin-wine-easy-packager") +#import mainwindow +window.setCentralWidget(modules.window) window.show() app.exec_() \ No newline at end of file