diff --git a/README.md b/README.md index ce32fd0..69dc5e3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# wine 运行器 1.5.2 +# wine 运行器 1.5.3 ## 介绍 一个图形化了以下命令的程序 @@ -9,7 +9,7 @@ env WINEPREFIX=容器路径 wine(wine的路径) 可执行文件路径 是使用 Python3 的 tkinter 构建的 (自己美术功底太差,图标只能在网络上找了) (测试平台:deepin 20.6;UOS 家庭版 21;Ubuntu 22.04) -![image.png](https://storage.deepin.org/thread/202207061004446872_image.png) +![Screenshot_20220707_215916.png](https://storage.deepin.org/thread/202207072207209350_Screenshot_20220707_215916.png) 而打包器可以方便的把您的 wine 容器打包成 deb 包供他人使用,程序创建的 deb 构建临时文件夹目录树如下: ```bash /XXX @@ -60,6 +60,13 @@ exe路径\' 参数 \' 5、.desktop 的图标只支持 PNG 格式和 SVG 格式,其他格式无法显示图标 ## 更新日志 +### 1.5.3 +**※1、新增专门的程序设置,支持设置 Wine 容器架构、DEBUG 信息是否输出、默认的 Wine、默认容器路径、是否使用终端打开和 Wine 参数** +**※2、修复了 wine 打包器的控件禁用不全和打包的 deb 用户残留的问题** +**※3、新增暗黑主题** +4、合并了 deepin wine 文管设置器 +![Screenshot_20220707_215916.png](https://storage.deepin.org/thread/202207072207209350_Screenshot_20220707_215916.png) + ### 1.5.2 **※1、添加并翻新了 deepin-wine5 打包器,改为 wine 打包器,支持常见 wine 的打包** **※2、新增 Visual Studio C++ 的安装程序** diff --git a/deb/DEBIAN/control b/deb/DEBIAN/control index 0bc1af4..cd0b29d 100644 --- a/deb/DEBIAN/control +++ b/deb/DEBIAN/control @@ -1,5 +1,5 @@ Package: spark-deepin-wine-runner -Version: 1.5.2 +Version: 1.5.3 Maintainer: gfdgd xi <3025613752@qq.com>, 为什么您不喜欢熊出没和阿布呢 Homepage: https://gitee.com/gfdgd-xi/deep-wine-runner Architecture: all diff --git a/deb/DEBIAN/postinst b/deb/DEBIAN/postinst index bfcfc83..187aaab 100755 --- a/deb/DEBIAN/postinst +++ b/deb/DEBIAN/postinst @@ -1,4 +1,5 @@ # !/bin/sh python3 -m pip install --upgrade ttkthemes -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com +python3 -m pip install --upgrade ttkbootstrap -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com # 向服务器返回安装数加1(不显示内容且忽略错误) -curl http://120.25.153.144/spark-deepin-wine-runner/Install.php?Version=1.5.2 -s > /dev/null | true +curl http://120.25.153.144/spark-deepin-wine-runner/Install.php?Version=1.5.3 -s > /dev/null | true diff --git a/deb/opt/apps/deepin-wine-runner/deepin-wine-packager.py b/deb/opt/apps/deepin-wine-runner/deepin-wine-packager.py index 2cab876..3c75032 100755 --- a/deb/opt/apps/deepin-wine-runner/deepin-wine-packager.py +++ b/deb/opt/apps/deepin-wine-runner/deepin-wine-packager.py @@ -8,6 +8,7 @@ ################# # 引入所需的库 ################# +from cProfile import run import os import sys import json @@ -76,6 +77,9 @@ def disabled_or_NORMAL_all(choose): button4.config(state=a) button5.config(state=a) option1.config(state=a) + chooseWineHelper.config(state=a) + chooseWineVersion.config(state=a) + def make_deb(): clean_textbox1_things() @@ -85,6 +89,9 @@ def make_deb(): disabled_or_NORMAL_all(True) label13_text_change("必填信息没有填写完整,无法继续构建 deb 包") return + if not messagebox.askyesno(title="提示", message="打包将会改动现在选择的容器,是否继续?"): + disabled_or_NORMAL_all(True) + return thread = threading.Thread(target=make_deb_threading) thread.start() @@ -166,6 +173,15 @@ def make_deb_threading(): os.mknod("{}/opt/apps/{}/files/run.sh".format(debPackagePath, e1_text.get())) os.mknod("{}/opt/apps/{}/info".format(debPackagePath, e1_text.get())) ############### + # 设置容器 + ############### + label13_text_change("正在设置 wine 容器") + 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@") + os.chdir(programPath) + ############### # 压缩容器 ############### label13_text_change("正在打包 wine 容器") @@ -335,6 +351,7 @@ fi run_command("chmod -Rv 644 {}/opt/apps/{}/files/run.sh".format(debPackagePath, e1_text.get())) run_command("chmod -Rv 644 {}/opt/apps/{}/info".format(debPackagePath, e1_text.get())) run_command("chmod -Rv 755 {}/opt/apps/{}/files/run.sh".format(debPackagePath, e1_text.get())) + run_command("chmod -Rv 755 {}/opt/apps/{}/entries/applications/{}.desktop".format(debPackagePath, e1_text.get(), e1_text.get())) ################ # 构建 deb 包 ################ @@ -345,9 +362,10 @@ fi ################ label13_text_change("完成构建!") disabled_or_NORMAL_all(True) - except Exception as e: - messagebox.showerror(title="错误", message="程序出现错误,错误信息:\n{}".format(traceback.format_exc())) + messagebox.showinfo(title="提示", message="打包完毕!") + except: traceback.print_exc() + messagebox.showerror(title="错误", message="程序出现错误,错误信息:\n{}".format(traceback.format_exc())) label13_text_change("deb 包构建出现错误:{}".format(repr(e))) chang_textbox1_things(traceback.format_exc()) disabled_or_NORMAL_all(True) @@ -411,11 +429,16 @@ def readtxt(path): f.close() # 关闭文本对象 return str # 返回结果 +# 获取用户主目录 +def get_home(): + return os.path.expanduser('~') + ############### # 程序信息 ############### # 如果要添加其他 wine,请在字典添加其名称和执行路径 wine = {"deepin-wine": "deepin-wine", "deepin-wine5": "deepin-wine5", "wine": "wine", "wine64": "wine64", "deepin-wine5 stable": "deepin-wine5-stable", "deepin-wine6 stable": "deepin-wine6-stable", "spark-wine7-devel": "spark-wine7-devel", "ukylin-wine": "ukylin-wine"} +os.chdir("/") programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string iconPath = "{}/icon.png".format(programPath) information = json.loads(readtxt(f"{programPath}/information.json")) @@ -431,7 +454,20 @@ tips = """提示: ############### # 窗口创建 ############### -window = tk.Tk() +# 读取主题 +try: + theme = not ("dark" in readtxt(get_home() + "/.gtkrc-2.0") and "gtk-theme-name=" in readtxt(get_home() + "/.gtkrc-2.0")) +except: + 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 = tk.StringVar() wineVersion.set("deepin-wine6 stable") @@ -452,22 +488,22 @@ option1_text = tk.StringVar() option1_text.set("Network") label13_text.set("当前 deb 打包情况:暂未打包") # 创建控件 -label1 = ttk.Label(window, text="要打包的 deb 包的包名(※必填)") -label2 = ttk.Label(window, text="要打包的 deb 包的版本号(※必填)") -label3 = ttk.Label(window, text="要打包的 deb 包的说明(※必填)") -label4 = ttk.Label(window, text="要打包的 deb 包的维护者(※必填)") -label5 = ttk.Label(window, text="要解压的 wine 容器的容器名(※必填)") -label6 = ttk.Label(window, text="要解压的 wine 容器(※必填)") -label7 = ttk.Label(window, text="要解压的 wine 容器里需要运行的可执行文件路径(※必填)") -label8 = ttk.Label(window, text="要显示的 .desktop 文件的名称(※必填)") -label9 = ttk.Label(window, text="要显示的 .desktop 文件的图标(选填)") -label10 = ttk.Label(window, text="要显示的 .desktop 文件的 MimeType 内容(选填)") -label12 = ttk.Label(window, text="打包 deb 的保存路径(※必填)") +label1 = ttk.Label(window, text="要打包的 deb 包的包名(※必填):") +label2 = ttk.Label(window, text="要打包的 deb 包的版本号(※必填):") +label3 = ttk.Label(window, text="要打包的 deb 包的说明(※必填):") +label4 = ttk.Label(window, text="要打包的 deb 包的维护者(※必填):") +label5 = ttk.Label(window, text="要解压的 wine 容器的容器名(※必填):") +label6 = ttk.Label(window, text="要解压的 wine 容器(※必填):") +label7 = ttk.Label(window, text="要解压的 wine 容器里需要运行的可执行文件路径(※必填):") +label8 = ttk.Label(window, text="要显示的 .desktop 文件的名称(※必填):") +label9 = ttk.Label(window, text="要显示的 .desktop 文件的图标(选填):") +label10 = ttk.Label(window, text="要显示的 .desktop 文件的 MimeType 内容(选填):") +label12 = ttk.Label(window, text="打包 deb 的保存路径(※必填):") label13 = ttk.Label(window, textvariable=label13_text) -label14 = ttk.Label(window, text="要显示的 .desktop 文件的分类(※必填)") -label15 = ttk.Label(window,text="要解压的 wine 容器里需要运行的可执行文件的参数(选填)") +label14 = ttk.Label(window, text="要显示的 .desktop 文件的分类(※必填):") +label15 = ttk.Label(window,text="要解压的 wine 容器里需要运行的可执行文件的参数(选填):") wineFrame = ttk.Frame(window) -chooseWineVersionTips = ttk.Label(window,text="选择打包的 wine 版本(必选)") +chooseWineVersionTips = ttk.Label(window,text="选择打包的 wine 版本(※必选):") chooseWineVersion = ttk.OptionMenu(wineFrame, wineVersion, "deepin-wine6 stable", *list(wine)) # 创建选择框控件 chooseWineHelperValue = tk.IntVar() chooseWineHelper = ttk.Checkbutton(wineFrame, text="使用星火wine helper(如不勾选默认为deepin-wine-helper)", variable=chooseWineHelperValue) @@ -498,8 +534,6 @@ help = tk.Menu(menu, tearoff=0) # 设置“帮助”菜单栏 menu.add_cascade(label="帮助", menu=help) help.add_command(label="小提示", command=helps) # 设置“小提示”项 # 设置窗口 -style = ttkthemes.ThemedStyle(window) -style.set_theme("breeze") window.title(f"wine 应用打包器 {version}") window.iconphoto(False, tk.PhotoImage(file=iconPath)) # 控件配置 diff --git a/deb/opt/apps/deepin-wine-runner/deepin-wine-runner b/deb/opt/apps/deepin-wine-runner/deepin-wine-runner index 079ee56..c9e3272 100755 --- a/deb/opt/apps/deepin-wine-runner/deepin-wine-runner +++ b/deb/opt/apps/deepin-wine-runner/deepin-wine-runner @@ -2,15 +2,18 @@ # 使用系统默认的 python3 运行 ########################################################################################### # 作者:gfdgd xi、为什么您不喜欢熊出没和阿布呢 -# 版本:1.5.2 -# 更新时间:2022年07月06日 +# 版本:1.5.3 +# 更新时间:2022年07月07日 # 感谢:感谢 wine 以及 deepin-wine 团队,提供了 wine 和 deepin-wine 给大家使用,让我能做这个程序 # 基于 Python3 的 tkinter 构建 ########################################################################################### ################# # 引入所需的库 ################# +from asyncore import read +from email import message import os +from sqlite3 import TimeFromTicks import sys import time import json @@ -101,19 +104,34 @@ def DisableButton(things): getProgramIcon.configure(state=a[things]) uninstallProgram.configure(state=a[things]) +def CheckProgramIsInstall(program): + return not bool(os.system(f"which '{program}'")) + # 运行可执行文件的线程 def runexebutton_threading(): DisableButton(True) + if not CheckProgramIsInstall(wine[o1_text.get()]): + if not tkinter.messagebox.askyesno(title="提示", message="检查到您未安装这个 wine,是否继续使用这个 wine 运行?"): + DisableButton(False) + return if e2.get() == "": # 判断文本框是否有内容 tkinter.messagebox.showinfo(title="提示", message="没有填写需要使用的 exe 应用") DisableButton(False) return else: # 如果都有 if e1.get() == "": - wineBottonPath = get_home() + "/.wine" + wineBottonPath = setting["DefultBotton"] else: wineBottonPath = e1.get() - res = subprocess.Popen(["WINEPREFIX='" + wineBottonPath + "' " + wine[o1_text.get()] + " '" + e2.get() + "'"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + option = "" + if setting["Architecture"] != "Auto": + option += f"WINEARCH={setting['Architecture']} " + if not setting["Debug"]: + option += "WINEDEBUG=-all " + if setting["TerminalOpen"]: + res = subprocess.Popen([f"'{programPath}/launch.sh' deepin-terminal -C \"WINEPREFIX='" + wineBottonPath + "' " + option + wine[o1_text.get()] + " '" + e2.get() + "' " + setting["WineOption"] + "\" --keep-open"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + else: + res = subprocess.Popen(["WINEPREFIX='" + wineBottonPath + "' " + option + wine[o1_text.get()] + " '" + e2.get() + "' " + setting["WineOption"]], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # 清空文本框内容 returnText.config(state=tk.NORMAL) returnText.delete(1.0, "end") @@ -169,6 +187,10 @@ def UpdateThings(): def make_desktop_on_launcher(): if combobox1.get() == "" or e2.get() == "": # 判断文本框是否有内容 tkinter.messagebox.showinfo(title="提示", message="没有填写需要使用 exe 应用或保存的文件名") + if not CheckProgramIsInstall(wine[o1_text.get()]): + if not tkinter.messagebox.askyesno(title="提示", message="检查到您未安装这个 wine,是否继续使用这个 wine 写入?"): + DisableButton(False) + return else: # 如果都有 if os.path.exists(get_home() + "/.local/share/applications/" + combobox1.get() + ".desktop"): # 判断目录是否有该文件,如果有 choose = tkinter.messagebox.askokcancel(title="提示", message="文件已经存在,是否覆盖?") # 询问用户是否覆盖 @@ -177,12 +199,17 @@ def make_desktop_on_launcher(): else: # 如不覆盖 return # 结束 if e1.get() == "": - wineBottonPath = get_home() + "/.wine" + wineBottonPath = setting["DefultBotton"] else: wineBottonPath = e1.get() + option = "" + if setting["Architecture"] != "Auto": + option += f"WINEARCH={setting['Architecture']} " + if not setting["Debug"]: + option += "WINEDEBUG=-all " write_txt(get_home() + "/.local/share/applications/" + combobox1.get() + ".desktop", f'''[Desktop Entry] Name={combobox1.get()} -Exec=env WINEPREFIX='{wineBottonPath}' {wine[o1_text.get()]} '{e2.get()}' +Exec=env WINEPREFIX='{wineBottonPath}' {option} {wine[o1_text.get()]} '{e2.get()}' {setting["WineOption"]} Icon={iconPath} Type=Application StartupNotify=true''') # 写入文本文档 @@ -196,6 +223,10 @@ StartupNotify=true''') # 写入文本文档 def make_desktop_on_desktop(): if combobox1.get() == "" or e2.get() == "": # 判断文本框是否有内容 tkinter.messagebox.showinfo(title="提示", message="没有填写需要使用的 exe 应用或保存的文件名") + if not CheckProgramIsInstall(wine[o1_text.get()]): + if not tkinter.messagebox.askyesno(title="提示", message="检查到您未安装这个 wine,是否继续使用这个 wine 写入?"): + DisableButton(False) + return else: # 如果都有 if os.path.exists(get_desktop_path() + "/" + combobox1.get() + ".desktop"): # 判断目录是否有该文件,如果有 choose = tkinter.messagebox.askokcancel(title="提示", message="文件已经存在,是否覆盖?") # 询问用户是否覆盖 @@ -204,13 +235,18 @@ def make_desktop_on_desktop(): else: # 如不覆盖 return # 结束 if e1.get() == "": - wineBottonPath = get_home() + "/.wine" + wineBottonPath = setting["DefultBotton"] else: wineBottonPath = e1.get() os.mknod(get_desktop_path() + "/" + combobox1.get() + ".desktop") + option = "" + if setting["Architecture"] != "Auto": + option += f"WINEARCH={setting['Architecture']} " + if not setting["Debug"]: + option += "WINEDEBUG=-all " write_txt(get_desktop_path() + "/" + combobox1.get() + ".desktop", f'''[Desktop Entry] Name={combobox1.get()} -Exec=env WINEPREFIX='{wineBottonPath}' {wine[o1_text.get()]} '{e2.get()}' +Exec=env WINEPREFIX='{wineBottonPath}' {option} {wine[o1_text.get()]} '{e2.get()}' {setting["WineOption"]} Icon={iconPath} Type=Application StartupNotify=true''') # 写入文本文档 @@ -245,14 +281,14 @@ def InstallWine(): def OpenWineBotton(): if e1.get() == "": - wineBottonPath = get_home() + "/.wine" + wineBottonPath = setting["DefultBotton"] else: wineBottonPath = e1.get() os.system("xdg-open \"" + wineBottonPath.replace("\'", "\\\'") + "\"") def OpenWineFontPath(): if e1.get() == "": - wineBottonPath = get_home() + "/.wine" + wineBottonPath = setting["DefultBotton"] else: wineBottonPath = e1.get() tkinter.messagebox.showinfo(title="提示", message="如果安装字体?只需要把字体文件复制到此字体目录\n按下“OK”按钮可以打开字体目录") @@ -269,12 +305,23 @@ def ConfigWineBotton(): def RunWineProgram(wineProgram, history = False, Disbled = True): DisableButton(True) + if not CheckProgramIsInstall(wine[o1_text.get()]): + if not tkinter.messagebox.askyesno(title="提示", message="检查到您未安装这个 wine,是否继续使用这个 wine 运行?"): + DisableButton(False) + return if e1.get() == "": - wineBottonPath = get_home() + "/.wine" + wineBottonPath = setting["DefultBotton"] else: wineBottonPath = e1.get() - print("WINEPREFIX='" + wineBottonPath + "' " + wine[o1_text.get()] + " '" + wineProgram + "'") - res = subprocess.Popen(["WINEPREFIX='" + wineBottonPath + "' " + wine[o1_text.get()] + " '" + wineProgram + "'"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + option = "" + if setting["Architecture"] != "Auto": + option += f"WINEARCH={setting['Architecture']} " + if not setting["Debug"]: + option += "WINEDEBUG=-all " + if setting["TerminalOpen"]: + res = subprocess.Popen([f"'{programPath}/launch.sh' deepin-terminal -C \"WINEPREFIX='" + wineBottonPath + "' " + option + wine[o1_text.get()] + " '" + wineProgram + "' " + setting["WineOption"] + "\" --keep-open"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + else: + res = subprocess.Popen(["WINEPREFIX='" + wineBottonPath + "' " + option + wine[o1_text.get()] + " '" + wineProgram + "' " + setting["WineOption"]], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # 清空文本框内容 returnText.config(state=tk.NORMAL) returnText.delete(1.0, "end") @@ -301,11 +348,22 @@ def RunWineProgram(wineProgram, history = False, Disbled = True): def RunWinetricks(): DisableButton(True) - wineBottonPath = get_home() + "/.wine" + if not CheckProgramIsInstall(wine[o1_text.get()]): + if not tkinter.messagebox.askyesno(title="提示", message="检查到您未安装这个 wine,是否继续使用这个 wine 运行?"): + DisableButton(False) + return + wineBottonPath = setting["DefultBotton"] if not e1.get() == "": wineBottonPath = e1.get() - print("WINEPREFIX='" + wineBottonPath + "' winetricks") - res = subprocess.Popen(["WINEPREFIX='" + wineBottonPath + "' winetricks"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + option = "" + if setting["Architecture"] != "Auto": + option += f"WINEARCH={setting['Architecture']} " + if not setting["Debug"]: + option += "WINEDEBUG=-all " + if setting["TerminalOpen"]: + res = subprocess.Popen([f"'{programPath}/launch.sh' deepin-terminal -C \"WINEPREFIX='" + option + wineBottonPath + "' winetricks\""], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + else: + res = subprocess.Popen(["WINEPREFIX='" + option + wineBottonPath + "' winetricks"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # 清空文本框内容 returnText.config(state=tk.NORMAL) returnText.delete(1.0, "end") @@ -325,7 +383,7 @@ def RunWinetricks(): def InstallMonoGecko(program): DisableButton(True) if e1.get() == "": - wineBottonPath = get_home() + "/.wine" + wineBottonPath = setting["DefultBotton"] else: wineBottonPath = e1.get() os.system(f"'{programPath}/launch.sh' deepin-terminal -C \"'{programPath}/InstallMono.py' '{wineBottonPath}' {wine[o1_text.get()]} {program}\" --keep-open") @@ -334,7 +392,7 @@ def InstallMonoGecko(program): def InstallNetFramework(): DisableButton(True) if e1.get() == "": - wineBottonPath = get_home() + "/.wine" + wineBottonPath = setting["DefultBotton"] else: wineBottonPath = e1.get() os.system(f"'{programPath}/launch.sh' deepin-terminal -C \"'{programPath}/InstallNetFramework.py' '{wineBottonPath}' {wine[o1_text.get()]}\" --keep-open") @@ -343,7 +401,7 @@ def InstallNetFramework(): def InstallVisualStudioCPlusPlus(): DisableButton(True) if e1.get() == "": - wineBottonPath = get_home() + "/.wine" + wineBottonPath = setting["DefultBotton"] else: wineBottonPath = e1.get() os.system(f"'{programPath}/launch.sh' deepin-terminal -C \"'{programPath}/InstallVisualCPlusPlus.py' '{wineBottonPath}' {wine[o1_text.get()]}\" --keep-open") @@ -351,11 +409,44 @@ def InstallVisualStudioCPlusPlus(): def BuildExeDeb(): if e1.get() == "": - wineBottonPath = get_home() + "/.wine" + wineBottonPath = setting["DefultBotton"] else: wineBottonPath = e1.get() threading.Thread(target=os.system, args=[f"python3 '{programPath}/deepin-wine-packager.py' '{wineBottonPath}' '{wine[o1_text.get()]}'"]).start() +def SetDeepinFileDialogDeepin(): + code = os.system(f"pkexec \"{programPath}/deepin-wine-venturi-setter.py\" deepin") + if code != 0: + if code == 1: + tkinter.messagebox.showerror(title="错误", message="无法更新配置:配置不准重复配置") + return + tkinter.messagebox.showerror(title="错误", message="配置失败") + +def SetDeepinFileDialogDefult(): + code = os.system(f"pkexec \"{programPath}/deepin-wine-venturi-setter.py\" defult") + if code != 0: + if code == 1: + tkinter.messagebox.showerror(title="错误", message="无法更新配置:配置不准重复配置") + return + tkinter.messagebox.showerror(title="错误", message="配置失败") + +def SetDeepinFileDialogRecovery(): + threading.Thread(target=os.system, args=[f"'{programPath}/launch.sh' deepin-terminal -C 'pkexec \"{programPath}/deepin-wine-venturi-setter.py\" recovery' --keep-open"]).start() + +def DeleteWineBotton(): + if not tkinter.messagebox.askokcancel(title="提示", message="你确定要删除容器吗?删除后将无法恢复!\n如果没有选择 wine 容器,将会自动删除默认的容器!"): + return + if e1.get() == "": + wineBottonPath = setting["DefultBotton"] + else: + wineBottonPath = e1.get() + try: + shutil.rmtree(wineBottonPath) + tkinter.messagebox.showinfo(title="提示", message="删除完毕!") + except: + traceback.print_exc() + tkinter.messagebox.showerror(title="错误", message=traceback.format_exc()) + class GetDllFromWindowsISO: wineBottonPath = get_home() + "/.wine" isoPath = None#ttk.Entry() @@ -407,7 +498,10 @@ class GetDllFromWindowsISO: GetDllFromWindowsISO.dllControl.grid(row=5, column=0, columnspan=3) GetDllFromWindowsISO.saveDll.grid(row=0, column=0) GetDllFromWindowsISO.setWineBotton.grid(row=0, column=1) + # 设置 GetDllFromWindowsISO.message.protocol('WM_DELETE_WINDOW', GetDllFromWindowsISO.ExitWindow) + GetDllFromWindowsISO.message.title("从 ISO 提取 DLL") + # 显示 GetDllFromWindowsISO.message.mainloop() def DisbledUp(state): @@ -518,12 +612,84 @@ class GetDllFromWindowsISO: if not tkinter.messagebox.askyesno(title="提示", message=f"DLL {choose} 已经存在,是否覆盖?"): continue print(i) - shutil.copy(f"/tmp/wine-runner-getdll/i386/{choose[:-1]}_", f"{GetDllFromWindowsISO.wineBottonPath}/drive_c/windows/system32/{choose}") + try: + shutil.copy(f"/tmp/wine-runner-getdll/i386/{choose[:-1]}_", f"{GetDllFromWindowsISO.wineBottonPath}/drive_c/windows/system32/{choose}") + tkinter.messagebox.showinfo(title="提示", message="提取成功!") + except: + traceback.print_exc() + tkinter.messagebox.showerror(title="错误", message=traceback.format_exc()) +class ProgramSetting(): + wineBottonA = None + wineDebug = None + defultWine = None + defultBotton = None + terminalOpen = None + wineOption = None + def ShowWindow(): + message = tk.Toplevel() + ProgramSetting.wineBottonA = tk.StringVar() + ProgramSetting.wineDebug = tk.IntVar() + ProgramSetting.wineDebug.set(int(setting["Debug"])) + ProgramSetting.defultWine = tk.StringVar() + ttk.Label(message, text="选择 Wine 容器版本:").grid(row=0, column=0, sticky=tk.W) + ttk.OptionMenu(message, ProgramSetting.wineBottonA, setting["Architecture"], "Auto", "win32", "win64").grid(row=0, column=1) + ttk.Label(message, text="wine DEBUG 信息输出:").grid(row=1, column=0, sticky=tk.W) + ttk.Checkbutton(message, text="开启 DEBUG 输出", variable=ProgramSetting.wineDebug).grid(row=1, column=1) + ttk.Label(message, text="默认 Wine:").grid(row=2, column=0, sticky=tk.W) + ttk.OptionMenu(message, ProgramSetting.defultWine, setting["DefultWine"], *list(wine)).grid(row=2, column=1) # 创建选择框控件 + ttk.Label(message, text="默认 Wine 容器:").grid(row=3, column=0, sticky=tk.W) + ProgramSetting.defultBotton = tk.StringVar() + ProgramSetting.defultBotton.set(setting["DefultBotton"]) + ttk.Entry(message, width=30, text=setting["DefultBotton"], textvariable=ProgramSetting.defultBotton).grid(row=3, column=1) + ttk.Button(message, text="浏览", command=ProgramSetting.Browser).grid(row=3, column=2) + ProgramSetting.terminalOpen = tk.IntVar() + ProgramSetting.terminalOpen.set(setting["TerminalOpen"]) + ttk.Label(message, text="使用终端打开:").grid(row=4, column=0) + ttk.Checkbutton(message, text="使用终端打开(deepin 终端)", variable=ProgramSetting.terminalOpen).grid(row=4, column=1, columnspan=2) + ttk.Label(message, text="自定义 wine 参数:").grid(row=5, column=0) + ProgramSetting.wineOption = tk.StringVar() + ProgramSetting.wineOption.set(setting["WineOption"]) + ttk.Entry(message, width=40, textvariable=ProgramSetting.wineOption).grid(row=5, column=1, columnspan=2) + ttk.Button(message, text="保存", command=ProgramSetting.Save).grid(row=6, column=0, columnspan=3, sticky=tk.E) + # 设置 + message.title(f"设置 wine 运行器 {version}") + # 显示 + message.mainloop() + + def Browser(): + path = tkinter.filedialog.askdirectory(title="选择 Wine 容器", initialdir=json.loads(readtxt(get_home() + "/.config/deepin-wine-runner/WineBotton.json"))["path"]) + if path == "" or path == None or path == "()" or path == (): + return + ProgramSetting.defultBotton.set(path) + + def Save(): + # 写入容器位数设置 + setting["Architecture"] = ProgramSetting.wineBottonA.get() + setting["Debug"] = bool(ProgramSetting.wineDebug.get()) + setting["DefultWine"] = ProgramSetting.defultWine.get() + setting["DefultBotton"] = ProgramSetting.defultBotton.get() + setting["TerminalOpen"] = bool(ProgramSetting.terminalOpen.get()) + setting["WineOption"] = ProgramSetting.wineOption.get() + try: + write_txt(get_home() + "/.config/deepin-wine-runner/WineSetting.json", json.dumps(setting)) + except: + traceback.print_exc() + tkinter.messagebox.showerror(title="错误", message=traceback.format_exc()) + return + tkinter.messagebox.showinfo(title="提示", message="保存完毕!") ########################### # 加载配置 ########################### +defultProgramList = { + "Architecture": "Auto", + "Debug": True, + "DefultWine": "deepin-wine6 stable", + "DefultBotton" : get_home() + "/.wine", + "TerminalOpen": False, + "WineOption": "" +} if not os.path.exists(get_home() + "/.config/deepin-wine-runner"): # 如果没有配置文件夹 os.mkdir(get_home() + "/.config/deepin-wine-runner") # 创建配置文件夹 if not os.path.exists(get_home() + "/.config/deepin-wine-runner/ShellHistory.json"): # 如果没有配置文件 @@ -542,17 +708,33 @@ if not os.path.exists(get_home() + "/.config/deepin-wine-runner/FindISO.json"): write_txt(get_home() + "/.config/deepin-wine-runner/FindISO.json", json.dumps({"path": "~"})) # 写入(创建)一个配置文件 if not os.path.exists(get_home() + "/.config/deepin-wine-runner/WineBotton.json"): # 如果没有配置文件 write_txt(get_home() + "/.config/deepin-wine-runner/WineBotton.json", json.dumps({"path": "~/.deepinwine"})) # 写入(创建)一个配置文件 +if not os.path.exists(get_home() + "/.config/deepin-wine-runner/WineSetting.json"): # 如果没有配置文件 + write_txt(get_home() + "/.config/deepin-wine-runner/WineSetting.json", json.dumps(defultProgramList)) # 写入(创建)一个配置文件 ########################### # 设置变量 ########################### # 如果要添加其他 wine,请在字典添加其名称和执行路径 -wine = {"deepin-wine": "deepin-wine", "deepin-wine5": "deepin-wine5", "wine": "wine", "wine64": "wine64", "deepin-wine5 stable": "deepin-wine5-stable", "deepin-wine6 stable": "deepin-wine6-stable", "spark-wine7-devel": "spark-wine7-devel", "ukylin-wine": "ukylin-wine"} -shellHistory = list(json.loads(readtxt(get_home() + "/.config/deepin-wine-runner/ShellHistory.json")).values()) -findExeHistory = list(json.loads(readtxt(get_home() + "/.config/deepin-wine-runner/FindExeHistory.json")).values()) -wineBottonHistory = list(json.loads(readtxt(get_home() + "/.config/deepin-wine-runner/WineBottonHistory.json")).values()) -isoPath = list(json.loads(readtxt(get_home() + "/.config/deepin-wine-runner/ISOPath.json")).values()) -isoPathFound = list(json.loads(readtxt(get_home() + "/.config/deepin-wine-runner/ISOPathFound.json")).values()) +try: + wine = {"deepin-wine": "deepin-wine", "deepin-wine5": "deepin-wine5", "wine": "wine", "wine64": "wine64", "deepin-wine5 stable": "deepin-wine5-stable", "deepin-wine6 stable": "deepin-wine6-stable", "spark-wine7-devel": "spark-wine7-devel", "ukylin-wine": "ukylin-wine"} + shellHistory = list(json.loads(readtxt(get_home() + "/.config/deepin-wine-runner/ShellHistory.json")).values()) + findExeHistory = list(json.loads(readtxt(get_home() + "/.config/deepin-wine-runner/FindExeHistory.json")).values()) + wineBottonHistory = list(json.loads(readtxt(get_home() + "/.config/deepin-wine-runner/WineBottonHistory.json")).values()) + isoPath = list(json.loads(readtxt(get_home() + "/.config/deepin-wine-runner/ISOPath.json")).values()) + isoPathFound = list(json.loads(readtxt(get_home() + "/.config/deepin-wine-runner/ISOPathFound.json")).values()) + setting = json.loads(readtxt(get_home() + "/.config/deepin-wine-runner/WineSetting.json")) + change = False + for i in ["Architecture", "Debug", "DefultWine", "DefultBotton", "TerminalOpen", "WineOption"]: + if not i in setting: + change = True + setting[i] = defultProgramList[i] + if change: + write_txt(get_home() + "/.config/deepin-wine-runner/WineSetting.json", json.dumps(setting)) +except: + root = tk.Tk() + root.withdraw() + tkinter.messagebox.showerror(title="错误", message="无法读取配置,无法继续") + sys.exit(1) ########################### # 程序信息 @@ -577,23 +759,34 @@ tips = '''提示: exe路径\' 参数 \' 即可(单引号需要输入) 5、wine 容器如果没有指定,则会默认为 ~/.wine''' -updateThingsString = '''※1、添加并翻新了 deepin-wine5 打包器,改为 wine 打包器,支持常见 wine 的打包 -※2、新增 Visual Studio C++ 的安装程序 -※3、新增从系统安装镜像提取 DLL 到 wine 容器的功能(当前只支持 Windows XP 和 Windows Server 2003 的官方安装镜像) -4、修复了安装星火应用商店的 wine 运行器右键打开方式没有 wine 运行器选项的问题 -5、新增脚本,优化 deepin terminal 调用本程序脚本显示不佳的问题 -''' +updateThingsString = '''※1、新增专门的程序设置,支持设置 Wine 容器架构、DEBUG 信息是否输出、默认的 Wine、默认容器路径、是否使用终端打开和 Wine 参数 +※2、修复了 wine 打包器的控件禁用不全和打包的 deb 用户残留的问题 +※3、新增暗黑主题 +4、合并了 deepin wine 文管设置器''' title = "wine 运行器 {}".format(version) -updateTime = "2022年07月06日" +updateTime = "2022年07月07日" updateThings = "{} 更新内容:\n{}\n更新时间:{}".format(version, updateThingsString, updateTime, time.strftime("%Y")) ########################### # 窗口创建 ########################### -win = tk.Tk() # 创建窗口 +# 读取主题 +try: + theme = not ("dark" in readtxt(get_home() + "/.gtkrc-2.0") and "gtk-theme-name=" in readtxt(get_home() + "/.gtkrc-2.0")) +except: + print("主题读取错误,默认使用浅色主题") + theme = True +if theme: + win = tk.Tk() + themes = ttkthemes.ThemedStyle(win) + themes.set_theme("breeze") +else: + import ttkbootstrap + style = ttkbootstrap.Style(theme="darkly") + win = style.master # 创建窗口 win.title(title) # 设置标题 -window = ttk.Frame() +window = tk.Frame() # 设置变量以修改和获取值项 o1_text = tk.StringVar() combobox1 = tk.StringVar() @@ -616,18 +809,19 @@ button5 = ttk.Button(sendFrame, text="创建用于运行的 desktop 文件到桌 saveDesktopFileOnLauncher = ttk.Button(sendFrame, text="创建用于运行的 desktop 文件到启动器", command=make_desktop_on_launcher) # 创建按钮控件 label1 = ttk.Label(window, text="选择你想要使用的 wine 容器:") # 创建标签控件 label2 = ttk.Label(window, text="选择要启动的 Windows 应用") # 创建标签控件 -label3 = ttk.Label(window, text="选择要使用的 wine 版本") # 创建标签控件 +label3 = ttk.Label(window, text="选择要使用的 wine 版本:") # 创建标签控件 label4 = ttk.Label(window, text="设置标题,以便把上方填写的信息写入到desktop文件里") # 创建标签控件 e1 = ttk.Combobox(window, width=100) # 创建文本框控件 e2 = ttk.Combobox(window, width=100) # 创建文本框控件 combobox1 = ttk.Combobox(window, width=100) -o1 = ttk.OptionMenu(window, o1_text, "deepin-wine6 stable", *list(wine)) # 创建选择框控件 -returnText = tk.Text(window) +o1 = ttk.OptionMenu(window, o1_text, setting["DefultWine"], *list(wine)) # 创建选择框控件 +returnText = tk.Text(window, width=150) menu = tk.Menu(window, background="white") # 设置菜单栏 programmenu = tk.Menu(menu, tearoff=0, background="white") # 设置“程序”菜单栏 menu.add_cascade(label="程序", menu=programmenu) programmenu.add_command(label="安装 wine", command=InstallWine) programmenu.add_separator() # 设置分界线 +programmenu.add_command(label="设置程序", command=ProgramSetting.ShowWindow) programmenu.add_command(label="清空软件历史记录", command=CleanProgramHistory) programmenu.add_separator() # 设置分界线 programmenu.add_command(label="退出程序", command=window.quit) # 设置“退出程序”项 @@ -641,9 +835,18 @@ wineOption.add_command(label="在指定wine、指定容器安装 .net framework" wineOption.add_command(label="在指定wine、指定容器安装 Visual Studio C++", command=lambda: threading.Thread(target=InstallVisualStudioCPlusPlus).start()) wineOption.add_command(label="在指定wine、指定容器安装 gecko", command=lambda: threading.Thread(target=InstallMonoGecko, args=["gecko"]).start()) wineOption.add_command(label="在指定wine、指定容器安装 mono", command=lambda: threading.Thread(target=InstallMonoGecko, args=["mono"]).start()) +wineOption.add_separator() +wineOption.add_command(label="打开指定wine、指定容器的控制面板", command=lambda: threading.Thread(target=RunWineProgram, args=["control"]).start()) +wineOption.add_command(label="打开指定wine、指定容器的浏览器", command=lambda: threading.Thread(target=RunWineProgram, args=["iexplore' 'https://www.deepin.org"]).start()) wineOption.add_command(label="打开指定wine、指定容器的注册表", command=lambda: threading.Thread(target=RunWineProgram, args=["regedit"]).start()) wineOption.add_command(label="打开指定wine、指定容器的任务管理器", command=lambda: threading.Thread(target=RunWineProgram, args=["taskmgr"]).start()) wineOption.add_command(label="打开指定wine、指定容器的关于 wine", command=lambda: threading.Thread(target=RunWineProgram, args=["winver"]).start()) +wineOption.add_separator() +wineOption.add_command(label="设置 run_v3.sh 的文管为 Deepin 默认文管", command=SetDeepinFileDialogDeepin) +wineOption.add_command(label="设置 run_v3.sh 的文管为 Wine 默认文管", command=SetDeepinFileDialogDefult) +wineOption.add_command(label="重新安装 deepin-wine-helper", command=SetDeepinFileDialogRecovery) +wineOption.add_separator() +wineOption.add_command(label="删除选择的 wine 容器", command=DeleteWineBotton) help = tk.Menu(menu, tearoff=0, background="white") # 设置“帮助”菜单栏 menu.add_cascade(label="帮助", menu=help) help.add_command(label="程序官网", command=OpenProgramURL) # 设置“程序官网”项 @@ -651,14 +854,16 @@ help.add_separator() help.add_command(label="小提示", command=helps) # 设置“小提示”项 help.add_command(label="更新内容", command=UpdateThings) # 设置“更新内容”项 help.add_command(label="关于这个程序", command=about_this_program) # 设置“关于这个程序”项 +help.add_separator() +moreProgram = tk.Menu(menu, tearoff=0, background="white") +help.add_cascade(label="更多生态适配应用", menu=moreProgram) +moreProgram.add_command(label="运行 Android 应用:UEngine 运行器", command=lambda: webbrowser.open_new_tab("https://gitee.com/gfdgd-xi/uengine-runner")) # 设置窗口 win.iconphoto(False, tk.PhotoImage(file=iconPath)) -themes = ttkthemes.ThemedStyle(win) -themes.set_theme("breeze") win.config(bg="white") # 设置控件 +e1.set(setting["DefultBotton"]) if len(sys.argv) > 1 and sys.argv[1]: - e1.set(f"{get_home()}/.wine") e2.set(sys.argv[1]) menu.configure(activebackground="dodgerblue") programmenu.configure(activebackground="dodgerblue") @@ -679,7 +884,6 @@ label3.grid(row=2, column=0) label4.grid(row=4, column=0) e1.grid(row=0, column=1) e2.grid(row=1, column=1) -#combobox1.grid(row=4, column=1) combobox1.grid(row=4, column=1) button1.grid(row=0, column=2) button2.grid(row=1, column=2) @@ -699,5 +903,5 @@ saveDesktopFileOnLauncher.grid(row=0, column=1) o1.grid(row=2, column=1) returnText.grid(row=6, column=0, columnspan=3) # 启动窗口 -window.pack() +window.pack(fill=tk.BOTH, expand = True) win.mainloop() diff --git a/deb/opt/apps/deepin-wine-runner/deepin-wine-venturi-setter.py b/deb/opt/apps/deepin-wine-runner/deepin-wine-venturi-setter.py new file mode 100755 index 0000000..0081af2 --- /dev/null +++ b/deb/opt/apps/deepin-wine-runner/deepin-wine-venturi-setter.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python3 +# 使用系统默认的 python3 运行 +########################################################################################### +# 作者:gfdgd xi、为什么您不喜欢熊出没和阿布呢 +# 版本:1.5.3 +# 更新时间:2022年07月07日 +# 感谢:感谢 wine 以及 deepin-wine 团队,提供了 wine 和 deepin-wine 给大家使用,让我能做这个程序 +# 基于 Python3 的 tkinter 构建 +########################################################################################### +################# +# 引入所需的库 +################# +import os +import sys + +################### +# 程序所需事件 +################### +# 读取文本文档 +def readtxt(path: "路径")->"读取文本文档": + f = open(path, "r") # 设置文件对象 + str = f.read() # 获取内容 + f.close() # 关闭文本对象 + return str # 返回结果 + + +def ChangeDeepinWineOpenFileDialogDefult()->"": + info = readtxt("/opt/deepinwine/tools/run_v3.sh") + all = "" + for line in info.split('\n'): + if "export ATTACH_FILE_DIALOG=" in line: + if "#" in line: + return False + line = "#" + line + all = all + line + "\n" + return all[0: -1] + +def ChangeDeepinWineOpenFileDialogDeepinDialog()->"": + info = readtxt("/opt/deepinwine/tools/run_v3.sh") + all = "" + for line in info.split('\n'): + if "export ATTACH_FILE_DIALOG=" in line: + if "#" not in line: + return False + line = line.replace("#", "") + all = all + line + "\n" + return all[0: -1] + +# 写入文本文档 +def write_txt(path: "路径", things: "内容")->"写入文本文档": + file = open(path, 'w', encoding='UTF-8') # 设置文件对象 + file.write(things) # 写入文本 + file.close() # 关闭文本对象 + +def Help(): + print("参数帮助:") + print("deepin\t使用 deepin 默认文管") + print("defult\t使用 wine 默认文管") + print("recovery\t恢复默认设置") + print("--help\t查看帮助") + +if len(sys.argv) <= 1: + print("参数错误!") + Help() + sys.exit(1) +if not sys.argv[1] == "deepin" and not sys.argv[1] == "defult" and not sys.argv[1] == "recovery" or sys.argv[1] == "--help": + Help() + sys.exit(1) +things = "" +if sys.argv[1] == "deepin": + things = ChangeDeepinWineOpenFileDialogDeepinDialog() +elif sys.argv[1] == "defult": + things = ChangeDeepinWineOpenFileDialogDefult() +elif sys.argv[1] == "recovery": + os.system("sudo apt reinstall deepin-wine-helper -y") + sys.exit(0) +else: + print("参数错误!") + Help() + sys.exit(1) +if things == False or things == "": + print("无法更新配置:配置不准重复更新") + sys.exit(1) +write_txt("/opt/deepinwine/tools/run_v3.sh", things) +sys.exit(0) diff --git a/deb/opt/apps/deepin-wine-runner/information.json b/deb/opt/apps/deepin-wine-runner/information.json index 3a1edf3..124e3d9 100644 --- a/deb/opt/apps/deepin-wine-runner/information.json +++ b/deb/opt/apps/deepin-wine-runner/information.json @@ -1,3 +1,3 @@ { - "Version": "1.5.2" + "Version": "1.5.3" } \ No newline at end of file diff --git a/deb/usr/bin/deepin-wine-venturi-setter b/deb/usr/bin/deepin-wine-venturi-setter new file mode 120000 index 0000000..154ba74 --- /dev/null +++ b/deb/usr/bin/deepin-wine-venturi-setter @@ -0,0 +1 @@ +/opt/apps/deepin-wine-runner/deepin-wine-venturi-setter.py \ No newline at end of file diff --git a/deb/usr/share/polkit-1/actions/com.deepin.pkexec.deepin-wine-venturi-setter.policy b/deb/usr/share/polkit-1/actions/com.deepin.pkexec.deepin-wine-venturi-setter.policy new file mode 100644 index 0000000..88fdac0 --- /dev/null +++ b/deb/usr/share/polkit-1/actions/com.deepin.pkexec.deepin-wine-venturi-setter.policy @@ -0,0 +1,21 @@ + + + + gfdgd xi + https://gitee.com/gfdgd-xi/deep-wine-runner/ + + Authentication is required to change run_v3 file manager + 修改 run_v3 文管需要输入密码 + preferences-system + + no + no + auth_admin_keep + + /opt/apps/deepin-wine-runner/deepin-wine-venturi-setter.py + true + + + \ No newline at end of file diff --git a/deepin-wine-packager.py b/deepin-wine-packager.py index 38a11c8..3c75032 100755 --- a/deepin-wine-packager.py +++ b/deepin-wine-packager.py @@ -429,6 +429,10 @@ def readtxt(path): f.close() # 关闭文本对象 return str # 返回结果 +# 获取用户主目录 +def get_home(): + return os.path.expanduser('~') + ############### # 程序信息 ############### @@ -450,7 +454,20 @@ tips = """提示: ############### # 窗口创建 ############### -window = tk.Tk() +# 读取主题 +try: + theme = not ("dark" in readtxt(get_home() + "/.gtkrc-2.0") and "gtk-theme-name=" in readtxt(get_home() + "/.gtkrc-2.0")) +except: + 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 = tk.StringVar() wineVersion.set("deepin-wine6 stable") @@ -471,22 +488,22 @@ option1_text = tk.StringVar() option1_text.set("Network") label13_text.set("当前 deb 打包情况:暂未打包") # 创建控件 -label1 = ttk.Label(window, text="要打包的 deb 包的包名(※必填)") -label2 = ttk.Label(window, text="要打包的 deb 包的版本号(※必填)") -label3 = ttk.Label(window, text="要打包的 deb 包的说明(※必填)") -label4 = ttk.Label(window, text="要打包的 deb 包的维护者(※必填)") -label5 = ttk.Label(window, text="要解压的 wine 容器的容器名(※必填)") -label6 = ttk.Label(window, text="要解压的 wine 容器(※必填)") -label7 = ttk.Label(window, text="要解压的 wine 容器里需要运行的可执行文件路径(※必填)") -label8 = ttk.Label(window, text="要显示的 .desktop 文件的名称(※必填)") -label9 = ttk.Label(window, text="要显示的 .desktop 文件的图标(选填)") -label10 = ttk.Label(window, text="要显示的 .desktop 文件的 MimeType 内容(选填)") -label12 = ttk.Label(window, text="打包 deb 的保存路径(※必填)") +label1 = ttk.Label(window, text="要打包的 deb 包的包名(※必填):") +label2 = ttk.Label(window, text="要打包的 deb 包的版本号(※必填):") +label3 = ttk.Label(window, text="要打包的 deb 包的说明(※必填):") +label4 = ttk.Label(window, text="要打包的 deb 包的维护者(※必填):") +label5 = ttk.Label(window, text="要解压的 wine 容器的容器名(※必填):") +label6 = ttk.Label(window, text="要解压的 wine 容器(※必填):") +label7 = ttk.Label(window, text="要解压的 wine 容器里需要运行的可执行文件路径(※必填):") +label8 = ttk.Label(window, text="要显示的 .desktop 文件的名称(※必填):") +label9 = ttk.Label(window, text="要显示的 .desktop 文件的图标(选填):") +label10 = ttk.Label(window, text="要显示的 .desktop 文件的 MimeType 内容(选填):") +label12 = ttk.Label(window, text="打包 deb 的保存路径(※必填):") label13 = ttk.Label(window, textvariable=label13_text) -label14 = ttk.Label(window, text="要显示的 .desktop 文件的分类(※必填)") -label15 = ttk.Label(window,text="要解压的 wine 容器里需要运行的可执行文件的参数(选填)") +label14 = ttk.Label(window, text="要显示的 .desktop 文件的分类(※必填):") +label15 = ttk.Label(window,text="要解压的 wine 容器里需要运行的可执行文件的参数(选填):") wineFrame = ttk.Frame(window) -chooseWineVersionTips = ttk.Label(window,text="选择打包的 wine 版本(必选)") +chooseWineVersionTips = ttk.Label(window,text="选择打包的 wine 版本(※必选):") chooseWineVersion = ttk.OptionMenu(wineFrame, wineVersion, "deepin-wine6 stable", *list(wine)) # 创建选择框控件 chooseWineHelperValue = tk.IntVar() chooseWineHelper = ttk.Checkbutton(wineFrame, text="使用星火wine helper(如不勾选默认为deepin-wine-helper)", variable=chooseWineHelperValue) @@ -517,8 +534,6 @@ help = tk.Menu(menu, tearoff=0) # 设置“帮助”菜单栏 menu.add_cascade(label="帮助", menu=help) help.add_command(label="小提示", command=helps) # 设置“小提示”项 # 设置窗口 -style = ttkthemes.ThemedStyle(window) -style.set_theme("breeze") window.title(f"wine 应用打包器 {version}") window.iconphoto(False, tk.PhotoImage(file=iconPath)) # 控件配置 diff --git a/main.py b/main.py index d76137c..c9e3272 100755 --- a/main.py +++ b/main.py @@ -11,6 +11,7 @@ # 引入所需的库 ################# from asyncore import read +from email import message import os from sqlite3 import TimeFromTicks import sys @@ -432,6 +433,20 @@ def SetDeepinFileDialogDefult(): def SetDeepinFileDialogRecovery(): threading.Thread(target=os.system, args=[f"'{programPath}/launch.sh' deepin-terminal -C 'pkexec \"{programPath}/deepin-wine-venturi-setter.py\" recovery' --keep-open"]).start() +def DeleteWineBotton(): + if not tkinter.messagebox.askokcancel(title="提示", message="你确定要删除容器吗?删除后将无法恢复!\n如果没有选择 wine 容器,将会自动删除默认的容器!"): + return + if e1.get() == "": + wineBottonPath = setting["DefultBotton"] + else: + wineBottonPath = e1.get() + try: + shutil.rmtree(wineBottonPath) + tkinter.messagebox.showinfo(title="提示", message="删除完毕!") + except: + traceback.print_exc() + tkinter.messagebox.showerror(title="错误", message=traceback.format_exc()) + class GetDllFromWindowsISO: wineBottonPath = get_home() + "/.wine" isoPath = None#ttk.Entry() @@ -744,12 +759,10 @@ tips = '''提示: exe路径\' 参数 \' 即可(单引号需要输入) 5、wine 容器如果没有指定,则会默认为 ~/.wine''' -updateThingsString = '''※1、添加并翻新了 deepin-wine5 打包器,改为 wine 打包器,支持常见 wine 的打包 -※2、新增 Visual Studio C++ 的安装程序 -※3、新增从系统安装镜像提取 DLL 到 wine 容器的功能(当前只支持 Windows XP 和 Windows Server 2003 的官方安装镜像) -4、修复了安装星火应用商店的 wine 运行器右键打开方式没有 wine 运行器选项的问题 -5、新增脚本,优化 deepin terminal 调用本程序脚本显示不佳的问题 -''' +updateThingsString = '''※1、新增专门的程序设置,支持设置 Wine 容器架构、DEBUG 信息是否输出、默认的 Wine、默认容器路径、是否使用终端打开和 Wine 参数 +※2、修复了 wine 打包器的控件禁用不全和打包的 deb 用户残留的问题 +※3、新增暗黑主题 +4、合并了 deepin wine 文管设置器''' title = "wine 运行器 {}".format(version) updateTime = "2022年07月07日" updateThings = "{} 更新内容:\n{}\n更新时间:{}".format(version, updateThingsString, updateTime, time.strftime("%Y")) @@ -758,9 +771,22 @@ updateThings = "{} 更新内容:\n{}\n更新时间:{}".format(version, updat ########################### # 窗口创建 ########################### -win = tk.Tk() # 创建窗口 +# 读取主题 +try: + theme = not ("dark" in readtxt(get_home() + "/.gtkrc-2.0") and "gtk-theme-name=" in readtxt(get_home() + "/.gtkrc-2.0")) +except: + print("主题读取错误,默认使用浅色主题") + theme = True +if theme: + win = tk.Tk() + themes = ttkthemes.ThemedStyle(win) + themes.set_theme("breeze") +else: + import ttkbootstrap + style = ttkbootstrap.Style(theme="darkly") + win = style.master # 创建窗口 win.title(title) # 设置标题 -window = ttk.Frame() +window = tk.Frame() # 设置变量以修改和获取值项 o1_text = tk.StringVar() combobox1 = tk.StringVar() @@ -783,13 +809,13 @@ button5 = ttk.Button(sendFrame, text="创建用于运行的 desktop 文件到桌 saveDesktopFileOnLauncher = ttk.Button(sendFrame, text="创建用于运行的 desktop 文件到启动器", command=make_desktop_on_launcher) # 创建按钮控件 label1 = ttk.Label(window, text="选择你想要使用的 wine 容器:") # 创建标签控件 label2 = ttk.Label(window, text="选择要启动的 Windows 应用") # 创建标签控件 -label3 = ttk.Label(window, text="选择要使用的 wine 版本") # 创建标签控件 +label3 = ttk.Label(window, text="选择要使用的 wine 版本:") # 创建标签控件 label4 = ttk.Label(window, text="设置标题,以便把上方填写的信息写入到desktop文件里") # 创建标签控件 e1 = ttk.Combobox(window, width=100) # 创建文本框控件 e2 = ttk.Combobox(window, width=100) # 创建文本框控件 combobox1 = ttk.Combobox(window, width=100) o1 = ttk.OptionMenu(window, o1_text, setting["DefultWine"], *list(wine)) # 创建选择框控件 -returnText = tk.Text(window) +returnText = tk.Text(window, width=150) menu = tk.Menu(window, background="white") # 设置菜单栏 programmenu = tk.Menu(menu, tearoff=0, background="white") # 设置“程序”菜单栏 menu.add_cascade(label="程序", menu=programmenu) @@ -819,6 +845,8 @@ wineOption.add_separator() wineOption.add_command(label="设置 run_v3.sh 的文管为 Deepin 默认文管", command=SetDeepinFileDialogDeepin) wineOption.add_command(label="设置 run_v3.sh 的文管为 Wine 默认文管", command=SetDeepinFileDialogDefult) wineOption.add_command(label="重新安装 deepin-wine-helper", command=SetDeepinFileDialogRecovery) +wineOption.add_separator() +wineOption.add_command(label="删除选择的 wine 容器", command=DeleteWineBotton) help = tk.Menu(menu, tearoff=0, background="white") # 设置“帮助”菜单栏 menu.add_cascade(label="帮助", menu=help) help.add_command(label="程序官网", command=OpenProgramURL) # 设置“程序官网”项 @@ -829,11 +857,9 @@ help.add_command(label="关于这个程序", command=about_this_program) # 设 help.add_separator() moreProgram = tk.Menu(menu, tearoff=0, background="white") help.add_cascade(label="更多生态适配应用", menu=moreProgram) -moreProgram.add_command(label="UEngine 运行器", command=lambda: webbrowser.open_new_tab("https://gitee.com/gfdgd-xi/uengine-runner")) +moreProgram.add_command(label="运行 Android 应用:UEngine 运行器", command=lambda: webbrowser.open_new_tab("https://gitee.com/gfdgd-xi/uengine-runner")) # 设置窗口 win.iconphoto(False, tk.PhotoImage(file=iconPath)) -themes = ttkthemes.ThemedStyle(win) -themes.set_theme("breeze") win.config(bg="white") # 设置控件 e1.set(setting["DefultBotton"]) @@ -858,7 +884,6 @@ label3.grid(row=2, column=0) label4.grid(row=4, column=0) e1.grid(row=0, column=1) e2.grid(row=1, column=1) -#combobox1.grid(row=4, column=1) combobox1.grid(row=4, column=1) button1.grid(row=0, column=2) button2.grid(row=1, column=2) @@ -878,5 +903,5 @@ saveDesktopFileOnLauncher.grid(row=0, column=1) o1.grid(row=2, column=1) returnText.grid(row=6, column=0, columnspan=3) # 启动窗口 -window.pack() +window.pack(fill=tk.BOTH, expand = True) win.mainloop()