基本完成!

This commit is contained in:
gfdgd xi 2022-07-18 22:20:19 +08:00
parent 99d1255d93
commit e9f24c2cc0
5 changed files with 304 additions and 342 deletions

View File

@ -1,6 +1,3 @@
# !/bin/sh # !/bin/sh
python3 -m pip install --upgrade ttkthemes --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple
python3 -m pip install --upgrade ttkbootstrap --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple
python3 -m pip install --upgrade easygui --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple
# 向服务器返回安装数加1不显示内容且忽略错误 # 向服务器返回安装数加1不显示内容且忽略错误
curl http://120.25.153.144/spark-deepin-wine-runner/Install.php?Version=1.6.1 -s > /dev/null | true curl http://120.25.153.144/spark-deepin-wine-runner/Install.php?Version=1.7.0 -s > /dev/null | true

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
######################################################################### #########################################################################
# 作者gfdgd xi、为什么您不喜欢熊出没和阿布 # 作者gfdgd xi、为什么您不喜欢熊出没和阿布
# 版本1.6.1 # 版本1.7.0
# 感谢:感谢 deepin-wine 团队,提供了 deepin-wine 给大家使用,让我能做这个程序 # 感谢:感谢 deepin-wine 团队,提供了 deepin-wine 给大家使用,让我能做这个程序
# 基于 Python3 的 tkinter 构建 # 基于 Python3 的 tkinter 构建
######################################################################### #########################################################################
@ -14,197 +14,203 @@ import json
import shutil import shutil
import random import random
import pathlib import pathlib
import ttkthemes
import threading
import traceback import traceback
import subprocess import subprocess
from PIL import Image from PIL import Image
import tkinter as tk import PyQt5.QtGui as QtGui
import tkinter.ttk as ttk import PyQt5.QtCore as QtCore
import PyQt5.QtWidgets as QtWidgets import PyQt5.QtWidgets as QtWidgets
import tkinter.messagebox as messagebox
import tkinter.filedialog as filedialog
################# #################
# 程序所需事件 # 程序所需事件
################# #################
def button1_cl(): def button1_cl():
path = filedialog.askdirectory(title="选择 wine 容器", initialdir="~/.deepinwine") path = QtWidgets.QFileDialog.getExistingDirectory(widget, "选择 wine 容器", f"{get_home()}/.deepinwine")
if path != "": if path != "":
e6_text.set(path) e6_text.setText(path)
def button2_cl(): def button2_cl():
path = filedialog.askopenfilename(filetypes=[("PNG图标", "*.png"), ("SVG图标", "*.svg"), ("全部文件", "*.*")], title="选择图标文件", initialdir="~") path = QtWidgets.QFileDialog.getOpenFileName(widget, "选择图标文件", get_home(), "PNG图标(*.png);;SVG图标(*.svg);;全部文件(*.*)")[0]
if path != "": if path != "":
e9_text.set(path) e9_text.setText(path)
def button4_cl(): def button4_cl():
path = filedialog.asksaveasfilename(filetypes=[("deb 文件", "*.deb"), ("所有文件", "*.*")], title="保存 deb 包", initialdir="~", initialfile="{}_{}_i386.deb".format(e1_text.get(), e2_text.get())) path = QtWidgets.QFileDialog.getSaveFileName(widget, "保存 deb 包", get_home(), "deb 文件(*.deb);;所有文件(*.*)", "{}_{}_i386.deb".format(e1_text.text(), e2_text.text()))[0]
if path != "": if path != "":
e12_text.set(path) e12_text.setText(path)
def disabled_or_NORMAL_all(choose): def disabled_or_NORMAL_all(choose):
chooses = {True: tk.NORMAL, False: tk.DISABLED} choose = not choose
a = chooses[choose] e1_text.setDisabled(choose)
label1.configure(state=a) e2_text.setDisabled(choose)
label2.configure(state=a) e3_text.setDisabled(choose)
label3.configure(state=a) e4_text.setDisabled(choose)
label4.configure(state=a) e5_text.setDisabled(choose)
label5.configure(state=a) e6_text.setDisabled(choose)
label6.configure(state=a) e7_text.setDisabled(choose)
label7.configure(state=a) e8_text.setDisabled(choose)
label8.configure(state=a) e9_text.setDisabled(choose)
label9.configure(state=a) e10_text.setDisabled(choose)
label10.configure(state=a) e12_text.setDisabled(choose)
label12.configure(state=a) e15_text.setDisabled(choose)
label14.configure(state=a) button1.setDisabled(choose)
label15.configure(state=a) button2.setDisabled(choose)
e1.configure(state=a) button4.setDisabled(choose)
e2.configure(state=a) button5.setDisabled(choose)
e3.configure(state=a) option1_text.setDisabled(choose)
e4.configure(state=a) chooseWineHelperValue.setDisabled(choose)
e5.configure(state=a) wineVersion.setDisabled(choose)
e6.configure(state=a)
e7.configure(state=a)
e8.configure(state=a)
e9.configure(state=a)
e10.configure(state=a)
e12.configure(state=a)
e15.configure(state=a)
button1.config(state=a)
button2.config(state=a)
button4.config(state=a)
button5.config(state=a)
option1.config(state=a)
chooseWineHelper.config(state=a)
chooseWineVersion.config(state=a)
class QT:
thread = None
def make_deb(): def make_deb():
clean_textbox1_things() clean_textbox1_things()
disabled_or_NORMAL_all(False) disabled_or_NORMAL_all(False)
if e1_text.get() == "" or e2_text.get() == "" or e3_text.get() == "" or e4_text.get() == "" or e5_text.get() == "" or e6_text.get() == "" or e7_text.get() == "" or e8_text.get() == "" or e12_text.get() == "": if e1_text.text() == "" or e2_text.text() == "" or e3_text.text() == "" or e4_text.text() == "" or e5_text.text() == "" or e6_text.text() == "" or e7_text.text() == "" or e8_text.text() == "" or e12_text.text() == "":
messagebox.showinfo(title="提示", message="必填信息没有填写完整,无法继续构建 deb 包") QtWidgets.QMessageBox.critical(widget, "错误", "必填信息没有填写完整,无法继续构建 deb 包")
disabled_or_NORMAL_all(True) disabled_or_NORMAL_all(True)
label13_text_change("必填信息没有填写完整,无法继续构建 deb 包") label13_text_change("必填信息没有填写完整,无法继续构建 deb 包")
return return
if not messagebox.askyesno(title="提示", message="打包将会改动现在选择的容器,是否继续?"): if QtWidgets.QMessageBox.question(widget, "提示", "打包将会改动现在选择的容器,是否继续?") == QtWidgets.QMessageBox.No:
disabled_or_NORMAL_all(True) disabled_or_NORMAL_all(True)
return return
thread = threading.Thread(target=make_deb_threading) #thread = threading.Thread(target=make_deb_threading)
thread.start() QT.thread = make_deb_threading()
QT.thread.signal.connect(chang_textbox1_things)
QT.thread.label.connect(label13_text_change)
QT.thread.start()
#thread.start()
def label13_text_change(thing): def label13_text_change(thing):
label13_text.set("当前 deb 打包情况:{}".format(thing)) label13_text.setText(f"<p align='center'>当前 deb 打包情况:{thing}</p>")
def make_deb_threading(): class make_deb_threading(QtCore.QThread):
##################################### signal = QtCore.pyqtSignal(str)
# 程序创建的 deb 构建临时文件夹目录树: label = QtCore.pyqtSignal(str)
# /XXX def __init__(self) -> None:
# ├── DEBIAN super().__init__()
# │ ├── control
# │ └── postrm def run_command(self, command):
# └── opt res = subprocess.Popen([command], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
# └── apps # 实时读取程序返回
# └── XXX while res.poll() is None:
# ├── entries
# │ ├── applications
# │ │ └── XXX.desktop
# │ └── icons
# │ └── hicolor
# │ └── scalable
# │ └── apps
# │ └── XXX.pngXXX.svg
# ├── files
# │ ├── files.7z
# │ └── run.sh
# └── info
#
# 11 directories, 6 files
#####################################
try:
#####################
# 判断文件是否存在
#####################
label13_text_change("正在检查文件是否存在并为后面步骤准备……")
a = ""
if e6_text.get() == "/":
b = e6_text.get()[:-1]
else:
b = e6.get()
if e9_text.get() != "":
# 获取图片格式(不太准)
try: try:
im = Image.open(e9_text.get()) text = res.stdout.readline().decode("utf8")
imms = im.format.lower() except:
except: # 未知(就直接设置为 svg 后缀) text = ""
imms = ".svg" print(text, end="")
a = "/opt/apps/{}/entries/icons/hicolor/scalable/apps/{}.{}".format(e1_text.get(), e1_text.get(), imms) self.signal.emit(text)
if not os.path.exists(e9_text.get()):
messagebox.showerror(title="提示", message="图标的路径填写错误,无法进行构建 deb 包") def run(self):
#####################################
# 程序创建的 deb 构建临时文件夹目录树:
# /XXX
# ├── DEBIAN
# │ ├── control
# │ └── postrm
# └── opt
# └── apps
# └── XXX
# ├── entries
# │ ├── applications
# │ │ └── XXX.desktop
# │ └── icons
# │ └── hicolor
# │ └── scalable
# │ └── apps
# │ └── XXX.pngXXX.svg
# ├── files
# │ ├── files.7z
# │ └── run.sh
# └── info
#
# 11 directories, 7 files
#####################################
try:
#####################
# 判断文件是否存在
#####################
self.label.emit("正在检查文件是否存在并为后面步骤准备……")
a = ""
if e6_text.text() == "/":
b = e6_text.text()[:-1]
else:
b = e6_text.text()
if e9_text.text() != "":
# 获取图片格式(不太准)
try:
im = Image.open(e9_text.text())
imms = im.format.lower()
except: # 未知(就直接设置为 svg 后缀)
imms = ".svg"
a = "/opt/apps/{}/entries/icons/hicolor/scalable/apps/{}.{}".format(e1_text.text(), e1_text.text(), imms)
if not os.path.exists(e9_text.text()):
QtWidgets.QMessageBox.critical(widget, "错误", "图标的路径填写错误,无法进行构建 deb 包")
disabled_or_NORMAL_all(True)
label13_text_change("图标的路径填写错误,无法进行构建 deb 包")
return
if not os.path.exists(e6_text.text()):
QtWidgets.QMessageBox.critical(widget, "错误", "路径填写错误,无法继续构建 deb 包")
disabled_or_NORMAL_all(True) disabled_or_NORMAL_all(True)
label13_text_change("图标的路径填写错误,无法进行构建 deb 包") label13_text_change("图标的路径填写错误,无法进行构建 deb 包")
return return
if not os.path.exists(e6_text.get()): #############
messagebox.showerror(title="提示", message="路径填写错误,无法继续构建 deb 包") # 删除文件
disabled_or_NORMAL_all(True) #############
label13_text_change("图标的路径填写错误,无法进行构建 deb 包") self.label.emit("正在删除对构建 deb 包有影响的文件……")
return debPackagePath = f"/tmp/{random.randint(0, 9999)}"
############# self.run_command(f"rm -rfv /tmp/{debPackagePath}")
# 删除文件 ###############
############# # 创建目录
label13_text_change("正在删除对构建 deb 包有影响的文件……") ###############
debPackagePath = f"/tmp/{random.randint(0, 9999)}" self.label.emit("正在创建目录……")
run_command(f"rm -rfv /tmp/{debPackagePath}") os.makedirs("{}/DEBIAN".format(debPackagePath))
############### os.makedirs("{}/opt/apps/{}/entries/applications".format(debPackagePath, e1_text.text()))
# 创建目录 os.makedirs("{}/opt/apps/{}/entries/icons/hicolor/scalable/apps".format(debPackagePath, e1_text.text()))
############### os.makedirs("{}/opt/apps/{}/files".format(debPackagePath, e1_text.text()))
label13_text_change("正在创建目录……") ###############
os.makedirs("{}/DEBIAN".format(debPackagePath)) # 创建文件
os.makedirs("{}/opt/apps/{}/entries/applications".format(debPackagePath, e1_text.get())) ###############
os.makedirs("{}/opt/apps/{}/entries/icons/hicolor/scalable/apps".format(debPackagePath, e1_text.get())) self.label.emit("正在创建文件……")
os.makedirs("{}/opt/apps/{}/files".format(debPackagePath, e1_text.get())) os.mknod("{}/DEBIAN/control".format(debPackagePath))
############### os.mknod("{}/opt/apps/{}/entries/applications/{}.desktop".format(debPackagePath, e1_text.text(), e1_text.text()))
# 创建文件 os.mknod("{}/opt/apps/{}/files/run.sh".format(debPackagePath, e1_text.text()))
############### os.mknod("{}/opt/apps/{}/info".format(debPackagePath, e1_text.text()))
label13_text_change("正在创建文件……") ###############
os.mknod("{}/DEBIAN/control".format(debPackagePath)) # 设置容器
os.mknod("{}/opt/apps/{}/entries/applications/{}.desktop".format(debPackagePath, e1_text.get(), e1_text.get())) ###############
os.mknod("{}/opt/apps/{}/files/run.sh".format(debPackagePath, e1_text.get())) self.label.emit("正在设置 wine 容器")
os.mknod("{}/opt/apps/{}/info".format(debPackagePath, e1_text.get())) os.chdir(b)
############### self.run_command("sed -i \"s#$USER#@current_user@#\" ./*.reg")
# 设置容器 os.chdir(f"{b}/drive_c/users")
############### self.run_command(f"mv -v '{os.getlogin()}' @current_user@")
label13_text_change("正在设置 wine 容器") os.chdir(programPath)
os.chdir(b) ###############
run_command("sed -i \"s#$USER#@current_user@#\" ./*.reg") # 压缩容器
os.chdir(f"{b}/drive_c/users") ###############
run_command(f"mv -v '{os.getlogin()}' @current_user@") self.label.emit("正在打包 wine 容器")
os.chdir(programPath) self.run_command("7z a {}/opt/apps/{}/files/files.7z {}/*".format(debPackagePath, e1_text.text(), b))
############### ###############
# 压缩容器 # 复制图片
############### ###############
label13_text_change("正在打包 wine 容器") self.label.emit("正在复制文件……")
run_command("7z a {}/opt/apps/{}/files/files.7z {}/*".format(debPackagePath, e1_text.get(), b)) self.run_command(f"cp -rv '{programPath}/dlls' {debPackagePath}/opt/apps/{e1_text.text()}/files/")
############### if e9_text.text() != "":
# 复制图片 shutil.copy(e9_text.text(), "{}/opt/apps/{}/entries/icons/hicolor/scalable/apps/{}.{}".format(debPackagePath, e1_text.text(), e1_text.text(), imms))
############### ################
label13_text_change("正在复制文件……") # 获取文件大小
run_command(f"cp -rv '{programPath}/dlls' {debPackagePath}/opt/apps/{e1_text.get()}/files/") ################
if e9_text.get() != "": self.label.emit("正在计算文件大小……")
shutil.copy(e9_text.get(), "{}/opt/apps/{}/entries/icons/hicolor/scalable/apps/{}.{}".format(debPackagePath, e1_text.get(), e1_text.get(), imms)) size = getFileFolderSize(debPackagePath) / 1024
################ ################
# 获取文件大小 # 写入文本文档
################ ################
label13_text_change("正在计算文件大小……") self.label.emit("正在写入文件……")
size = getFileFolderSize(debPackagePath) / 1024 if not chooseWineHelperValue.isChecked():
################ write_txt("{}/DEBIAN/control".format(debPackagePath), '''Package: {}
# 写入文本文档
################
label13_text_change("正在写入文件……")
if not bool(chooseWineHelperValue.get()):
write_txt("{}/DEBIAN/control".format(debPackagePath), '''Package: {}
Version: {} Version: {}
Architecture: i386 Architecture: i386
Maintainer: {} Maintainer: {}
@ -213,9 +219,9 @@ Section: non-free/otherosfs
Priority: optional Priority: optional
Multi-Arch: foreign Multi-Arch: foreign
Description: {} Description: {}
'''.format(e1_text.get(), e2_text.get(), e4_text.get(), wineVersion.get(), e3_text.get())) '''.format(e1_text.text(), e2_text.text(), e4_text.text(), wineVersion.currentText(), e3_text.text()))
else: else:
write_txt("{}/DEBIAN/postrm".format(debPackagePath), '''Package: {} write_txt("{}/DEBIAN/postrm".format(debPackagePath), '''Package: {}
Version: {} Version: {}
Architecture: i386 Architecture: i386
Maintainer: {} Maintainer: {}
@ -224,8 +230,8 @@ Section: non-free/otherosfs
Priority: optional Priority: optional
Multi-Arch: foreign Multi-Arch: foreign
Description: {} Description: {}
'''.format(e1_text.get(), e2_text.get(), e4_text.get(), wineVersion.get(), e3_text.get())) '''.format(e1_text.text(), e2_text.text(), e4_text.text(), wineVersion.currentText(), e3_text.text()))
write_txt("{}/opt/apps/{}/files/run.sh".format(debPackagePath, e1_text.get()), f'''#!/bin/bash write_txt("{}/opt/apps/{}/files/run.sh".format(debPackagePath, e1_text.text()), f'''#!/bin/bash
if [ "$1" = "remove" ] || [ "$1" = "purge" ];then if [ "$1" = "remove" ] || [ "$1" = "purge" ];then
@ -233,18 +239,18 @@ echo"清理卸载残留"
for username in ls /home for username in ls /home
do do
echo /home/$username echo /home/$username
if [ -d "/home/$username/.deepinwine/{e5_text.get()}" ] if [ -d "/home/$username/.deepinwine/{e5_text.text()}" ]
then then
rm -rf "/home/$username/.deepinwine/{e5_text.get()}" rm -rf "/home/$username/.deepinwine/{e5_text.text()}"
fi fi
done done
else else
echo"非卸载,跳过清理" echo"非卸载,跳过清理"
fi fi
''') ''')
write_txt("{}/opt/apps/{}/entries/applications/{}.desktop".format(debPackagePath, e1_text.get(), e1_text.get()), '#!/usr/bin/env xdg-open\n[Desktop Entry]\nEncoding=UTF-8\nType=Application\nX-Created-By={}\nCategories={};\nIcon={}\nExec="/opt/apps/{}/files/run.sh" {}\nName={}\nComment={}\nMimeType={}\nGenericName={}\nTerminal=false\nStartupNotify=false\n'.format(e4_text.get(), option1_text.get(), a, e1_text.get(), e15_text.get(), e8_text.get(), e3_text.get(), e10_text.get(), e1_text.get())) write_txt("{}/opt/apps/{}/entries/applications/{}.desktop".format(debPackagePath, e1_text.text(), e1_text.text()), '#!/usr/bin/env xdg-open\n[Desktop Entry]\nEncoding=UTF-8\nType=Application\nX-Created-By={}\nCategories={};\nIcon={}\nExec="/opt/apps/{}/files/run.sh" {}\nName={}\nComment={}\nMimeType={}\nGenericName={}\nTerminal=false\nStartupNotify=false\n'.format(e4_text.text(), option1_text.currentText(), a, e1_text.text(), e15_text.text(), e8_text.text(), e3_text.text(), e10_text.text(), e1_text.text()))
if not bool(chooseWineHelperValue.get()): if not bool(chooseWineHelperValue.text()):
write_txt("{}/opt/apps/{}/files/run.sh".format(debPackagePath, e1_text.get()), '''#!/bin/sh write_txt("{}/opt/apps/{}/files/run.sh".format(debPackagePath, e1_text.text()), '''#!/bin/sh
# Copyright (C) 2016 Deepin, Inc. # Copyright (C) 2016 Deepin, Inc.
# #
@ -288,9 +294,9 @@ if [ -n "$EXEC_PATH" ];then
else else
$START_SHELL_PATH $BOTTLENAME $APPVER "uninstaller.exe" "$@" $START_SHELL_PATH $BOTTLENAME $APPVER "uninstaller.exe" "$@"
fi fi
'''.format(e5_text.get(), e2_text.get(), e7_text.get(), e1_text.get(), wineVersion.get())) '''.format(e5_text.text(), e2_text.text(), e7_text.text(), e1_text.text(), wineVersion.currentText()))
else: else:
write_txt("{}/opt/apps/{}/files/run.sh".format(debPackagePath, e1_text.get()), '''#!/bin/sh write_txt("{}/opt/apps/{}/files/run.sh".format(debPackagePath, e1_text.text()), '''#!/bin/sh
# Copyright (C) 2016 Deepin, Inc. # Copyright (C) 2016 Deepin, Inc.
# #
@ -360,33 +366,33 @@ if [ -n "$EXEC_PATH" ];then
else else
$START_SHELL_PATH $BOTTLENAME $APPVER "uninstaller.exe" "$@" $START_SHELL_PATH $BOTTLENAME $APPVER "uninstaller.exe" "$@"
fi fi
'''.format(e5_text.get(), e2_text.get(), e7_text.get(), e1_text.get(), wineVersion.get())) '''.format(e5_text.text(), e2_text.text(), e7_text.text(), e1_text.text(), wineVersion.currentText()))
write_txt("{}/opt/apps/{}/info".format(debPackagePath, e1_text.get()), '{\n "appid": "' + e1_text.get() + '",\n "name": "' + e8_text.get() + '",\n "version": "' + e2_text.get() + '",\n "arch": ["i386"],\n "permissions": {\n "autostart": false,\n "notification": false,\n "trayicon": true,\n "clipboard": true,\n "account": false,\n "bluetooth": false,\n "camera": false,\n "audio_record": false,\n "installed_apps": false\n }\n}') write_txt("{}/opt/apps/{}/info".format(debPackagePath, e1_text.text()), '{\n "appid": "' + e1_text.text() + '",\n "name": "' + e8_text.text() + '",\n "version": "' + e2_text.text() + '",\n "arch": ["i386"],\n "permissions": {\n "autostart": false,\n "notification": false,\n "trayicon": true,\n "clipboard": true,\n "account": false,\n "bluetooth": false,\n "camera": false,\n "audio_record": false,\n "installed_apps": false\n }\n}')
################ ################
# 修改文件权限 # 修改文件权限
################ ################
label13_text_change("正在修改文件权限……") self.label.emit("正在修改文件权限……")
run_command("chmod -Rv 644 {}/opt/apps/{}/files/run.sh".format(debPackagePath, e1_text.get())) self.run_command("chmod -Rv 644 {}/opt/apps/{}/files/run.sh".format(debPackagePath, e1_text.text()))
run_command("chmod -Rv 644 {}/opt/apps/{}/info".format(debPackagePath, e1_text.get())) self.run_command("chmod -Rv 644 {}/opt/apps/{}/info".format(debPackagePath, e1_text.text()))
run_command("chmod -Rv 755 {}/opt/apps/{}/files/run.sh".format(debPackagePath, e1_text.get())) self.run_command("chmod -Rv 755 {}/opt/apps/{}/files/run.sh".format(debPackagePath, e1_text.text()))
run_command("chmod -Rv 755 {}/opt/apps/{}/entries/applications/{}.desktop".format(debPackagePath, e1_text.get(), e1_text.get())) self.run_command("chmod -Rv 755 {}/opt/apps/{}/entries/applications/{}.desktop".format(debPackagePath, e1_text.text(), e1_text.text()))
################ ################
# 构建 deb 包 # 构建 deb 包
################ ################
label13_text_change("正在构建 deb 包……") self.label.emit("正在构建 deb 包……")
run_command("dpkg -b {} {}".format(debPackagePath, e12_text.get())) self.run_command("dpkg -b {} {}".format(debPackagePath, e12_text.text()))
################ ################
# 完成构建 # 完成构建
################ ################
label13_text_change("完成构建!") self.label.emit("完成构建!")
disabled_or_NORMAL_all(True) disabled_or_NORMAL_all(True)
messagebox.showinfo(title="提示", message="打包完毕!") QtWidgets.QMessageBox.information(widget, "提示", "打包完毕!")
except: except:
traceback.print_exc() traceback.print_exc()
messagebox.showerror(title="错误", message="程序出现错误,错误信息:\n{}".format(traceback.format_exc())) QtWidgets.QMessageBox.critical(widget, "错误", "程序出现错误,错误信息:\n{}".format(traceback.format_exc()))
label13_text_change("deb 包构建出现错误") self.label.emit("deb 包构建出现错误")
chang_textbox1_things(traceback.format_exc()) self.signal.emit(traceback.format_exc())
disabled_or_NORMAL_all(True) disabled_or_NORMAL_all(True)
# 写入文本文档 # 写入文本文档
def write_txt(path, things): def write_txt(path, things):
@ -395,25 +401,12 @@ def write_txt(path, things):
file.close() # 关闭文本对象 file.close() # 关闭文本对象
def chang_textbox1_things(things): def chang_textbox1_things(things):
textbox1.configure(state=tk.NORMAL) if things.replace("\n", "").replace(" ", "") == "":
textbox1.insert('end', things) return
textbox1.configure(state=tk.DISABLED) textbox1.append(things)
def clean_textbox1_things(): def clean_textbox1_things():
textbox1.configure(state=tk.NORMAL) textbox1.setText("")
textbox1.delete('1.0','end')
textbox1.configure(state=tk.DISABLED)
def run_command(command):
res = subprocess.Popen([command], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
# 实时读取程序返回
while res.poll() is None:
try:
text = res.stdout.readline().decode("utf8")
except:
text = ""
print(text)
chang_textbox1_things(text)
def getFileFolderSize(fileOrFolderPath): def getFileFolderSize(fileOrFolderPath):
@ -438,7 +431,7 @@ def getFileFolderSize(fileOrFolderPath):
# 显示“提示”窗口 # 显示“提示”窗口
def helps(): def helps():
messagebox.showinfo(title="提示", message=tips) QtWidgets.QMessageBox.information(widget, "提示", tips)
# 读取文本文档 # 读取文本文档
def readtxt(path): def readtxt(path):
@ -473,132 +466,97 @@ tips = """提示:
############### ###############
# 窗口创建 # 窗口创建
############### ###############
# 读取主题 app = QtWidgets.QApplication(sys.argv)
try: window = QtWidgets.QMainWindow()
theme = not ("dark" in readtxt(get_home() + "/.gtkrc-2.0") and "gtk-theme-name=" in readtxt(get_home() + "/.gtkrc-2.0")) widget = QtWidgets.QWidget()
except: widgetLayout = QtWidgets.QGridLayout()
print("主题读取错误,默认使用浅色主题")
theme = True
if theme:
window = tk.Tk()
themes = ttkthemes.ThemedStyle(window)
themes.set_theme("breeze")
else:
import ttkbootstrap
style = ttkbootstrap.Style(theme="darkly")
window = style.master # 创建窗口
# 设置变量以修改和获取值项 # 设置变量以修改和获取值项
wineVersion = QtWidgets.QComboBox() wineVersion = QtWidgets.QComboBox()
wineVersion.addItems wineVersion.addItems(wine.keys())
wineVersion.set("deepin-wine6 stable") wineVersion.setCurrentText("deepin-wine6 stable")
e1_text = tk.StringVar() e1_text = QtWidgets.QLineEdit()
e2_text = tk.StringVar() e2_text = QtWidgets.QLineEdit()
e3_text = tk.StringVar() e3_text = QtWidgets.QLineEdit()
e4_text = tk.StringVar() e4_text = QtWidgets.QLineEdit()
e5_text = tk.StringVar() e5_text = QtWidgets.QLineEdit()
e6_text = tk.StringVar() e6_text = QtWidgets.QLineEdit()
e7_text = tk.StringVar() e7_text = QtWidgets.QLineEdit()
e8_text = tk.StringVar() e8_text = QtWidgets.QLineEdit()
e9_text = tk.StringVar() e9_text = QtWidgets.QLineEdit()
e10_text = tk.StringVar() e10_text = QtWidgets.QLineEdit()
e12_text = tk.StringVar() e12_text = QtWidgets.QLineEdit()
e15_text = tk.StringVar() e15_text = QtWidgets.QLineEdit()
label13_text = tk.StringVar() label13_text = QtWidgets.QLabel("<p align='center'>当前 deb 打包情况:暂未打包</p>")
option1_text = tk.StringVar() option1_text = QtWidgets.QComboBox()
option1_text.set("Network") button1 = QtWidgets.QPushButton("浏览……")
label13_text.set("当前 deb 打包情况:暂未打包") button2 = QtWidgets.QPushButton("浏览……")
button4 = QtWidgets.QPushButton("浏览……")
button5 = QtWidgets.QPushButton("打包……")
textbox1 = QtWidgets.QTextBrowser()
option1_text.addItems(["Network", "Chat", "Audio", "Video", "Graphics", "Office", "Translation", "Development", "Utility", "System"])
option1_text.setCurrentText("Network")
wineFrame = QtWidgets.QHBoxLayout()
chooseWineHelperValue = QtWidgets.QCheckBox("使用星火wine helper如不勾选默认为deepin-wine-helper")
button1.clicked.connect(button1_cl)
button2.clicked.connect(button2_cl)
button4.clicked.connect(button4_cl)
button5.clicked.connect(make_deb)
wineFrame.addWidget(wineVersion)
wineFrame.addWidget(chooseWineHelperValue)
# 创建控件 # 创建控件
label1 = ttk.Label(window, text="要打包的 deb 包的包名(※必填):") widgetLayout.addWidget(QtWidgets.QLabel("要打包的 deb 包的包名(※必填):"), 0, 0, 1, 1)
label2 = ttk.Label(window, text="要打包的 deb 包的版本号(※必填):") widgetLayout.addWidget(QtWidgets.QLabel("要打包的 deb 包的版本号(※必填):"), 1, 0, 1, 1)
label3 = ttk.Label(window, text="要打包的 deb 包的说明(※必填):") widgetLayout.addWidget(QtWidgets.QLabel("要打包的 deb 包的说明(※必填):"), 2, 0, 1, 1)
label4 = ttk.Label(window, text="要打包的 deb 包的维护者(※必填):") widgetLayout.addWidget(QtWidgets.QLabel("要打包的 deb 包的维护者(※必填):"), 3, 0, 1, 1)
label5 = ttk.Label(window, text="要解压的 wine 容器的容器名(※必填):") widgetLayout.addWidget(QtWidgets.QLabel("要解压的 wine 容器的容器名(※必填):"), 4, 0, 1, 1)
label6 = ttk.Label(window, text="要解压的 wine 容器(※必填):") widgetLayout.addWidget(QtWidgets.QLabel("要解压的 wine 容器(※必填):"), 5, 0, 1, 1)
label7 = ttk.Label(window, text="要解压的 wine 容器里需要运行的可执行文件路径(※必填):") widgetLayout.addWidget(QtWidgets.QLabel("要解压的 wine 容器里需要运行的可执行文件路径(※必填):"), 6, 0, 1, 1)
label8 = ttk.Label(window, text="要显示的 .desktop 文件的名称(※必填):") widgetLayout.addWidget(QtWidgets.QLabel("要显示的 .desktop 文件的分类(※必填):"), 7, 0, 1, 1)
label9 = ttk.Label(window, text="要显示的 .desktop 文件的图标(选填):") widgetLayout.addWidget(QtWidgets.QLabel("要解压的 wine 容器里需要运行的可执行文件的参数(选填):"), 8, 0, 1, 1)
label10 = ttk.Label(window, text="要显示的 .desktop 文件的 MimeType 内容(选填):") widgetLayout.addWidget(QtWidgets.QLabel("要显示的 .desktop 文件的名称(※必填):"), 9, 0, 1, 1)
label12 = ttk.Label(window, text="打包 deb 的保存路径(※必填):") widgetLayout.addWidget(QtWidgets.QLabel("要显示的 .desktop 文件的图标(选填):"), 10, 0, 1, 1)
label13 = ttk.Label(window, textvariable=label13_text) widgetLayout.addWidget(QtWidgets.QLabel("要显示的 .desktop 文件的 MimeType 内容(选填):"), 11, 0, 1, 1)
label14 = ttk.Label(window, text="要显示的 .desktop 文件的分类(※必填):") widgetLayout.addWidget(QtWidgets.QLabel("选择打包的 wine 版本(※必选):"), 12, 0, 1, 1)
label15 = ttk.Label(window,text="要解压的 wine 容器里需要运行的可执行文件的参数(选填):") widgetLayout.addWidget(QtWidgets.QLabel("打包 deb 的保存路径(※必填):"), 13, 0, 1, 1)
wineFrame = ttk.Frame(window) widgetLayout.addWidget(e1_text, 0, 1, 1, 1)
chooseWineVersionTips = ttk.Label(window,text="选择打包的 wine 版本(※必选):") widgetLayout.addWidget(e2_text, 1, 1, 1, 1)
chooseWineVersion = ttk.OptionMenu(wineFrame, wineVersion, "deepin-wine6 stable", *list(wine)) # 创建选择框控件 widgetLayout.addWidget(e3_text, 2, 1, 1, 1)
chooseWineHelperValue = tk.IntVar() widgetLayout.addWidget(e4_text, 3, 1, 1, 1)
chooseWineHelper = ttk.Checkbutton(wineFrame, text="使用星火wine helper如不勾选默认为deepin-wine-helper", variable=chooseWineHelperValue) widgetLayout.addWidget(e5_text, 4, 1, 1, 1)
e1 = ttk.Entry(window, textvariable=e1_text, width=100) widgetLayout.addWidget(e6_text, 5, 1, 1, 1)
e2 = ttk.Entry(window, textvariable=e2_text, width=100) widgetLayout.addWidget(button1, 5, 2, 1, 1)
e3 = ttk.Entry(window, textvariable=e3_text, width=100) widgetLayout.addWidget(e7_text, 6, 1, 1, 1)
e4 = ttk.Entry(window, textvariable=e4_text, width=100) widgetLayout.addWidget(option1_text, 7, 1, 1, 1)
e5 = ttk.Entry(window, textvariable=e5_text, width=100) widgetLayout.addWidget(e15_text, 8, 1, 1, 1)
e6 = ttk.Entry(window, textvariable=e6_text, width=100) widgetLayout.addWidget(e8_text, 9, 1, 1, 1)
e7 = ttk.Entry(window, textvariable=e7_text, width=100) widgetLayout.addWidget(e9_text, 10, 1, 1, 1)
e8 = ttk.Entry(window, textvariable=e8_text, width=100) widgetLayout.addWidget(button2, 10, 2, 1, 1)
e9 = ttk.Entry(window, textvariable=e9_text, width=100) widgetLayout.addWidget(e10_text, 11, 1, 1, 1)
e10 = ttk.Entry(window, textvariable=e10_text, width=100) widgetLayout.addLayout(wineFrame, 12, 1, 1, 1)
e12 = ttk.Entry(window, textvariable=e12_text, width=100) widgetLayout.addWidget(e12_text, 13, 1, 1, 1)
e15 = ttk.Entry(window, textvariable=e15_text, width=100) widgetLayout.addWidget(button4, 13, 2, 1, 1)
button1 = ttk.Button(window, text="浏览……", command=button1_cl) widgetLayout.addWidget(button5, 14, 1, 1, 1)
button2 = ttk.Button(window, text="浏览……", command=button2_cl) widgetLayout.addWidget(label13_text, 15, 0, 1, 3)
button4 = ttk.Button(window, text="浏览……", command=button4_cl) widgetLayout.addWidget(textbox1, 16, 0, 1, 3)
button5 = ttk.Button(window, text="打包……", command=make_deb) menu = window.menuBar()
option1 = ttk.OptionMenu(window, option1_text, "Network", "Network", "Chat", "Audio", "Video", "Graphics", "Office", "Translation", "Development", "Utility", "System") programmenu = menu.addMenu("程序")
textbox1 = tk.Text(window, width=100, height=4) help = menu.addMenu("帮助")
textbox1.configure(state=tk.DISABLED) exit = QtWidgets.QAction("退出程序")
menu = tk.Menu(window) # 设置菜单栏 tip = QtWidgets.QAction("小提示")
programmenu = tk.Menu(menu, tearoff=0) # 设置“程序”菜单栏 exit.triggered.connect(window.close)
menu.add_cascade(label="程序", menu=programmenu) tip.triggered.connect(helps)
programmenu.add_command(label="退出程序", command=window.quit) # 设置“退出程序”项 programmenu.addAction(exit)
help = tk.Menu(menu, tearoff=0) # 设置“帮助”菜单栏 help.addAction(tip)
menu.add_cascade(label="帮助", menu=help)
help.add_command(label="小提示", command=helps) # 设置“小提示”项
# 设置窗口
window.title(f"wine 应用打包器 {version}")
window.iconphoto(False, tk.PhotoImage(file=iconPath))
# 控件配置 # 控件配置
try: try:
e6_text.set(sys.argv[1]) e6_text.setText(sys.argv[1])
e5_text.set(pathlib.PurePath(sys.argv[1]).name) e5_text.setText(pathlib.PurePath(sys.argv[1]).name)
wineVersion.set(sys.argv[2]) wineVersion.setCurrentText(sys.argv[2])
except: except:
pass pass
# 添加控件 widget.setLayout(widgetLayout)
window.config(menu=menu) # 显示菜单栏 window.setCentralWidget(widget)
label1.grid(row=0, column=0) window.setWindowTitle(f"wine 应用打包器 {version}")
e1.grid(row=0, column=1) window.setWindowIcon(QtGui.QIcon(iconPath))
label2.grid(row=1, column=0) window.show()
e2.grid(row=1, column=1) sys.exit(app.exec_())
label3.grid(row=2, column=0)
e3.grid(row=2, column=1)
label4.grid(row=3, column=0)
e4.grid(row=3, column=1)
label5.grid(row=4, column=0)
e5.grid(row=4, column=1)
label6.grid(row=5, column=0)
e6.grid(row=5, column=1)
button1.grid(row=5, column=2)
label7.grid(row=6, column=0)
e7.grid(row=6, column=1)
label14.grid(row=7, column=0)
option1.grid(row=7, column=1)
label15.grid(row=8, column=0)
e15.grid(row=8, column=1)
label8.grid(row=9, column=0)
e8.grid(row=9, column=1)
label9.grid(row=10, column=0)
e9.grid(row=10, column=1)
button2.grid(row=10, column=2)
label10.grid(row=11, column=0)
e10.grid(row=11, column=1)
chooseWineVersionTips.grid(row=12, column=0)
wineFrame.grid(row=12, column=1)
chooseWineVersion.grid(row=0, column=0)
chooseWineHelper.grid(row=0, column=1)
label12.grid(row=13, column=0)
e12.grid(row=13, column=1)
button4.grid(row=13, column=2)
button5.grid(row=14, column=1)
label13.grid(row=15, column=0, columnspan=3)
textbox1.grid(row=16, column=0, columnspan=3)
window.mainloop()

View File

@ -9,9 +9,9 @@
"感谢 @delsin 和 @神末shenmo 在 deepin 论坛提供打包器打包的 deb 包自动删除容器的建议", "感谢 @delsin 和 @神末shenmo 在 deepin 论坛提供打包器打包的 deb 包自动删除容器的建议",
"感谢 @GershonWang 在 https://github.com/gfdgd-xi/deep-wine-runner/issues/1 提供窗口居中的建议", "感谢 @GershonWang 在 https://github.com/gfdgd-xi/deep-wine-runner/issues/1 提供窗口居中的建议",
"感谢 @134******28 和 @sgb76 提供的新程序 GUI 布局和实现代码", "感谢 @134******28 和 @sgb76 提供的新程序 GUI 布局和实现代码",
"感谢统信在 wine 生态适配活动中提供的打包脚本", "感谢统信在 Wine 生态适配活动中提供的打包脚本",
"", "",
"可以从上面的各种解决方案更好的学习 Wine 生态适配,也可以看 deepin 论坛板块 https://bbs.deepin.org/module/detail/116 进行学习,最后也向各位有进行 Wine 生态适配的大佬进行由衷的更新", "可以从上面的各种解决方案更好的学习 Wine 生态适配,也可以看 deepin 论坛板块 https://bbs.deepin.org/module/detail/116 进行学习,最后也向各位有进行 Wine 生态适配的大佬进行由衷的感谢",
"如果上面有遗漏,请向我反馈补充" "如果上面有遗漏,请向我反馈补充"
] ]
} }

7
彩蛋提示.txt Normal file
View File

@ -0,0 +1,7 @@
你会发现在这个目录下有几个main-xxx.py的文件这个是界面的旧版/废稿,如果想要调用,需要输入以下命令:
```bash
sudo apt install python3 python3-tk python3-pip
python3 -m pip install --upgrade ttkthemes --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple
python3 -m pip install --upgrade ttkbootstrap --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple
python3 -m pip install --upgrade easygui --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple
```