This commit is contained in:
2021-07-27 15:05:19 +08:00
parent 8f021870d5
commit f003a29e48
13 changed files with 479 additions and 300 deletions

79
main.py
View File

@@ -2,7 +2,7 @@
# 使用系统默认的 python3 运行
###########################################################################################
# 作者gfdgd xi
# 版本1.3.2
# 版本1.4.0
# 更新时间2021年07月27日
# 感谢:感谢 wine 以及 deepin-wine 团队,提供了 wine 和 deepin-wine 给大家使用,让我能做这个程序
# 基于 Python3 的 tkinter 构建
@@ -10,17 +10,20 @@
#################
# 引入所需的库
#################
import tkinter as tk
import tkinter.ttk as ttk
import tkinter.filedialog
import tkinter.messagebox
import os
import sys
import time
import json
import shutil
import threading
import ttkthemes
import webbrowser
import tkinter as tk
import tkinter.ttk as ttk
import tkinter.filedialog
import tkinter.messagebox
import PIL.Image as Image
import PIL.ImageTk as ImageTk
###################
# 程序所需事件
@@ -101,7 +104,6 @@ def runexebutton_threading():
os.system("WINEPREFIX='" + e1.get() + "' " + wine[o1_text.get()] + " '" + e2.get() + "'") # 运行
findExeHistory.append(e1.get()) # 将记录写进数组
wineBottonHistory.append(e2.get()) # 将记录写进数组
print(ListToDictionary(findExeHistory))
write_txt(get_home() + "/.config/deepin-wine-runner/FindExeHistory.json", str(json.dumps(ListToDictionary(findExeHistory)))) # 将历史记录的数组转换为字典并写入
write_txt(get_home() + "/.config/deepin-wine-runner/WineBottonHistory.json", str(json.dumps(ListToDictionary(wineBottonHistory)))) # 将历史记录的数组转换为字典并写入
e1['value'] = findExeHistory
@@ -109,9 +111,24 @@ def runexebutton_threading():
DisableButton(False)
# 显示“关于这个程序”窗口
def about_this_program():
def about_this_program()->"显示“关于这个程序”窗口":
global about
tkinter.messagebox.showinfo(title="关于这个程序", message=about)
global title
global iconPath
mess = tk.Toplevel()
message = ttk.Frame(mess)
mess.resizable(0, 0)
mess.title("关于 {}".format(title))
mess.iconphoto(False, tk.PhotoImage(file=iconPath))
img = ImageTk.PhotoImage(Image.open(iconPath))
label1 = ttk.Label(message, image=img)
label2 = ttk.Label(message, text=about)
button1 = ttk.Button(message, text="确定", command=mess.withdraw)
label1.pack()
label2.pack()
button1.pack(side="bottom")
message.pack()
mess.mainloop()
# 显示“提示”窗口
def helps():
@@ -181,8 +198,6 @@ if not os.path.exists(get_home() + "/.config/deepin-wine-runner/WineBotton.json"
# 设置变量
###########################
# 如果要添加其他 wine请在字典添加其名称和执行路径
# 在数组添加其名称
wineName = ["deepin-wine", "deepin-wine","deepin-wine5", "wine", "wine64", "deepin-wine5 stable", "deepin-wine6 stable 32 位"]
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"}
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())
@@ -192,8 +207,9 @@ wineBottonHistory = list(json.loads(readtxt(get_home() + "/.config/deepin-wine-r
###########################
# 程序信息
###########################
iconPath = "{}/icon.png".format(os.path.split(os.path.realpath(__file__))[0])
programUrl = "https://gitee.com/gfdgd-xi/deep-wine-runner"
version = "1.3.2"
version = "1.4.0"
goodRunSystem = "Linux"
about = '''一个基于 Python3 的 tkinter 制作的 wine 运行器
版本:{}
@@ -202,9 +218,18 @@ tkinter 版本:{}
程序官网:{}
©2020-{} gfdgd xi'''.format(version, goodRunSystem, tk.TkVersion, programUrl, time.strftime("%Y"))
tips = '''提示:
1、使用终端运行该程序可以看到 wine 以及程序本身的提示和报错
2、wine 32 位和 64 位的容器互不兼容'''
updateThingsString = '''1、修改了 wine 选项的说明和 wine 的启动方式'''
1、使用终端运行该程序可以看到 wine 以及程序本身的提示和报错;
2、wine 32 位和 64 位的容器互不兼容;
3、部分 wine 系统没有预装,本程序没有设置任何 wine 的依赖项,如果需要使用请自行安装'''
updateThingsString = '''*1、修改了 wine 选项的说明和 wine 的启动方式;
*2、设置了窗口主题;
*3、修改了打包以及 .desktop 文件
4、删除了以前的残略调试代码;
5、优化了 wine 列表的显示流程;
6、更新了“关于”窗口
7、更新了提示内容
8、在 gitee/github 仓库上添加了 wine 安装脚本
'''
title = "wine 运行器 {}".format(version)
updateTime = "2021年07月27日"
updateThings = "{} 更新内容:\n{}\n更新时间:{}".format(version, updateThingsString, updateTime, time.strftime("%Y"))
@@ -213,8 +238,9 @@ updateThings = "{} 更新内容:\n{}\n更新时间{}".format(version, updat
###########################
# 窗口创建
###########################
window = tk.Tk() # 创建窗口
window.title(title) # 设置标题
win = tk.Tk() # 创建窗口
win.title(title) # 设置标题
window = ttk.Frame()
# 设置变量以修改和获取值项
o1_text = tk.StringVar()
combobox1 = tk.StringVar()
@@ -231,26 +257,34 @@ label4 = ttk.Label(window, text="设置文件名,以便把上方填写的信
e1 = ttk.Combobox(window, width=100) # 创建文本框控件
e2 = ttk.Combobox(window, width=100) # 创建文本框控件
combobox1 = ttk.Combobox(window, width=100)
o1 = ttk.OptionMenu(window, o1_text, *wineName) # 创建选择框控件
menu = tk.Menu(window) # 设置菜单栏
programmenu = tk.Menu(menu, tearoff=0) # 设置“程序”菜单栏
o1 = ttk.OptionMenu(window, o1_text, *list(wine)) # 创建选择框控件
menu = tk.Menu(window, background="white") # 设置菜单栏
programmenu = tk.Menu(menu, tearoff=0, background="white") # 设置“程序”菜单栏
menu.add_cascade(label="程序", menu=programmenu)
programmenu.add_command(label="清空软件历史记录", command=CleanProgramHistory)
programmenu.add_separator() # 设置分界线
programmenu.add_command(label="退出程序", command=window.quit) # 设置“退出程序”项
help = tk.Menu(menu, tearoff=0) # 设置“帮助”菜单栏
help = tk.Menu(menu, tearoff=0, background="white") # 设置“帮助”菜单栏
menu.add_cascade(label="帮助", menu=help)
help.add_command(label="程序官网", command=OpenProgramURL) # 设置“程序官网”项
help.add_separator()
help.add_command(label="小提示", command=helps) # 设置“小提示”项
help.add_command(label="更新内容", command=UpdateThings) # 设置“更新内容”项
help.add_command(label="关于这个程序", command=about_this_program) # 设置“关于这个程序”项
# 设置窗口
win.iconphoto(False, tk.PhotoImage(file=iconPath))
themes = ttkthemes.ThemedStyle(win)
themes.set_theme("adapta")
win.config(bg="white")
# 设置控件
menu.configure(activebackground="white")
programmenu.configure(activebackground="white")
help.configure(activebackground="white")
e1['value'] = findExeHistory
e2['value'] = wineBottonHistory
combobox1['value'] = shellHistory
# 添加控件
window.config(menu=menu) # 显示菜单栏
win.config(menu=menu) # 显示菜单栏
label1.grid(row=0, column=0)
label2.grid(row=1, column=0)
label3.grid(row=2, column=0)
@@ -265,4 +299,5 @@ button3.grid(row=3, column=0, columnspan=3)
button5.grid(row=5, column=0, columnspan=3)
o1.grid(row=2, column=1)
# 启动窗口
window.mainloop()
window.pack()
win.mainloop()