mirror of
https://gitee.com/gfdgd-xi/deep-wine-runner
synced 2025-02-05 12:58:02 +08:00
1.1.2——进行了细节优化
This commit is contained in:
parent
e41cb67097
commit
e7a8726d85
86
main.py
86
main.py
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#########################################################################
|
#########################################################################
|
||||||
# 作者:gfdgd xi
|
# 作者:gfdgd xi
|
||||||
# 版本:1.1.1
|
# 版本:1.1.2
|
||||||
# 感谢:感谢 deepin-wine 团队,提供了 deepin-wine 给大家使用,让我能做这个程序
|
# 感谢:感谢 deepin-wine 团队,提供了 deepin-wine 给大家使用,让我能做这个程序
|
||||||
# 基于 Python3 的 tkinter 构建
|
# 基于 Python3 的 tkinter 构建
|
||||||
#########################################################################
|
#########################################################################
|
||||||
@ -13,10 +13,15 @@ import tkinter.filedialog
|
|||||||
import tkinter.messagebox
|
import tkinter.messagebox
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
|
import webbrowser
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# 程序所需事件
|
# 程序所需事件
|
||||||
###################
|
###################
|
||||||
|
|
||||||
|
def OpenProgramURL():
|
||||||
|
webbrowser.open_new_tab("https://gitee.com/gfdgd-xi/deep-wine-runner")
|
||||||
|
|
||||||
# 读取文本文档
|
# 读取文本文档
|
||||||
def readtxt(path):
|
def readtxt(path):
|
||||||
f = open(path, "r") # 设置文件对象
|
f = open(path, "r") # 设置文件对象
|
||||||
@ -66,17 +71,28 @@ def runexebutton():
|
|||||||
run = threading.Thread(target = runexebutton_threading)
|
run = threading.Thread(target = runexebutton_threading)
|
||||||
run.start()
|
run.start()
|
||||||
|
|
||||||
|
def DisableButton(things):
|
||||||
|
a = {True: tk.DISABLED, False: tk.NORMAL}
|
||||||
|
button1.configure(state=a[things])
|
||||||
|
button2.configure(state=a[things])
|
||||||
|
button3.configure(state=a[things])
|
||||||
|
e1.configure(state=a[things])
|
||||||
|
e2.configure(state=a[things])
|
||||||
|
o1.configure(state=a[things])
|
||||||
|
|
||||||
# 运行可执行文件的线程
|
# 运行可执行文件的线程
|
||||||
def runexebutton_threading():
|
def runexebutton_threading():
|
||||||
|
DisableButton(True)
|
||||||
if e1_text.get() == "" or e2_text.get() == "": # 判断文本框是否有内容
|
if e1_text.get() == "" or e2_text.get() == "": # 判断文本框是否有内容
|
||||||
tkinter.messagebox.showinfo(title="提示",message="没有填写需要使用的 deepin-wine 容器或需要运行的 exe 应用")
|
tkinter.messagebox.showinfo(title="提示",message="没有填写需要使用的 deepin-wine 容器或需要运行的 exe 应用")
|
||||||
else: # 如果都有
|
else: # 如果都有
|
||||||
print("###############################")
|
print("###############################")
|
||||||
os.system("WINEPREFIX='" + e1_text.get() + "' " + o1_text.get() + " '" + e2_text.get() + "'") # 运行
|
os.system("WINEPREFIX='" + e1_text.get() + "' " + o1_text.get() + " '" + e2_text.get() + "'") # 运行
|
||||||
|
DisableButton(False)
|
||||||
|
|
||||||
# 显示“关于这个程序”窗口
|
# 显示“关于这个程序”窗口
|
||||||
def about_this_program():
|
def about_this_program():
|
||||||
tkinter.messagebox.showinfo(title="关于这个程序",message="一个基于 Python3 的 tkinter 制作的 deepin-wine(deepin-wine5) 运行器\n版本:1.1.1\n适用平台:Linux\ntkinter 版本:" + str(tk.TkVersion))
|
tkinter.messagebox.showinfo(title="关于这个程序", message="一个基于 Python3 的 tkinter 制作的 deepin-wine(deepin-wine5) 运行器\n版本:1.1.2\n适用平台:Linux\ntkinter 版本:" + str(tk.TkVersion) + "\n程序官网:https://gitee.com/gfdgd-xi/deep-wine-runner")
|
||||||
|
|
||||||
# 显示“提示”窗口
|
# 显示“提示”窗口
|
||||||
def helps():
|
def helps():
|
||||||
@ -85,25 +101,25 @@ def helps():
|
|||||||
# 生成 shell 文件在桌面
|
# 生成 shell 文件在桌面
|
||||||
# (第四个按钮的事件)
|
# (第四个按钮的事件)
|
||||||
def make_desktop_on_desktop():
|
def make_desktop_on_desktop():
|
||||||
if e3_text.get() == "" or e2_text.get() == "" or e1_text.get() == "": # 判断文本框是否有内容
|
if e3_text.get() == "" or e2_text.get() == "" or e1_text.get() == "": # 判断文本框是否有内容
|
||||||
tkinter.messagebox.showinfo(title="提示",message="没有填写需要使用的 deepin-wine 容器或需要运行的 exe 应用或保存的文件名")
|
tkinter.messagebox.showinfo(title="提示", message="没有填写需要使用的 deepin-wine 容器或需要运行的 exe 应用或保存的文件名")
|
||||||
else: # 如果都有
|
else: # 如果都有
|
||||||
if os.path.exists(get_desktop_path() + "/" + e3_text.get() + ".sh"): # 判断目录是否有该文件,如果有
|
if os.path.exists(get_desktop_path() + "/" + e3_text.get() + ".sh"): # 判断目录是否有该文件,如果有
|
||||||
choose = tkinter.messagebox.askokcancel(title="提示",message="文件已经存在,是否覆盖?") # 询问用户是否覆盖
|
choose = tkinter.messagebox.askokcancel(title="提示", message="文件已经存在,是否覆盖?") # 询问用户是否覆盖
|
||||||
if choose: # 如要覆盖
|
if choose: # 如要覆盖
|
||||||
os.remove(get_desktop_path() + "/" + e3_text.get() + ".sh") # 删除该文件
|
os.remove(get_desktop_path() + "/" + e3_text.get() + ".sh") # 删除该文件
|
||||||
else: # 如不覆盖
|
else: # 如不覆盖
|
||||||
return # 结束
|
return # 结束
|
||||||
os.mknod(get_desktop_path() + "/" + e3_text.get() + ".sh") # 创建文本文档
|
os.mknod(get_desktop_path() + "/" + e3_text.get() + ".sh") # 创建文本文档
|
||||||
write_txt(get_desktop_path() + "/" + e3_text.get() + ".sh", "#!/bin/bash\n" + "WINEPREFIX='" + e1_text.get() + "' " + o1_text.get() + " '" + e2_text.get() + "'") # 写入文本文档
|
write_txt(get_desktop_path() + "/" + e3_text.get() + ".sh", "#!/bin/bash\n" + "WINEPREFIX='" + e1_text.get() + "' " + o1_text.get() + " '" + e2_text.get() + "'") # 写入文本文档
|
||||||
os.system("chmod 777 '" + get_desktop_path() + "/" + e3_text.get() + ".sh" + "'") # 赋予可执行权限
|
os.system("chmod 777 '" + get_desktop_path() + "/" + e3_text.get() + ".sh" + "'") # 赋予可执行权限
|
||||||
tkinter.messagebox.showinfo(title="提示", message="生成完成!") # 显示完成对话框
|
tkinter.messagebox.showinfo(title="提示", message="生成完成!") # 显示完成对话框
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
# 窗口创建
|
# 窗口创建
|
||||||
###########################
|
###########################
|
||||||
window = tk.Tk() # 创建窗口
|
window = tk.Tk() # 创建窗口
|
||||||
window.title("deepin-wine 运行器") # 设置标题
|
window.title("deepin-wine 运行器") # 设置标题
|
||||||
# 设置变量以修改和获取值项
|
# 设置变量以修改和获取值项
|
||||||
e1_text = tk.StringVar()
|
e1_text = tk.StringVar()
|
||||||
e2_text = tk.StringVar()
|
e2_text = tk.StringVar()
|
||||||
@ -111,29 +127,31 @@ o1_text = tk.StringVar()
|
|||||||
e3_text = tk.StringVar()
|
e3_text = tk.StringVar()
|
||||||
o1_text.set("deepin-wine")
|
o1_text.set("deepin-wine")
|
||||||
# 创建控件
|
# 创建控件
|
||||||
label1 = tk.Label(window, text="选择你想要使用的 deepin-wine 容器:") # 创建标签控件
|
label1 = tk.Label(window, text="选择你想要使用的 deepin-wine 容器:") # 创建标签控件
|
||||||
e1 = tk.Entry(window, textvariable=e1_text, width=100) # 创建文本框控件
|
e1 = tk.Entry(window, textvariable=e1_text, width=100) # 创建文本框控件
|
||||||
button1 = tk.Button(window, text="浏览", command=liulanbutton) # 创建按钮控件
|
button1 = tk.Button(window, text="浏览", command=liulanbutton) # 创建按钮控件
|
||||||
label2 = tk.Label(window, text="选择要启动的 Windows 应用") # 创建标签控件
|
label2 = tk.Label(window, text="选择要启动的 Windows 应用") # 创建标签控件
|
||||||
e2 = tk.Entry(window, textvariable=e2_text, width=100) # 创建文本框控件
|
e2 = tk.Entry(window, textvariable=e2_text, width=100) # 创建文本框控件
|
||||||
button2 = tk.Button(window, text="浏览", command=liulanexebutton) # 创建按钮控件
|
button2 = tk.Button(window, text="浏览", command=liulanexebutton) # 创建按钮控件
|
||||||
label3 = tk.Label(window, text="选择要使用的 deepin-wine 版本") # 创建标签控件
|
label3 = tk.Label(window, text="选择要使用的 deepin-wine 版本") # 创建标签控件
|
||||||
o1 = tk.OptionMenu(window, o1_text, "deepin-wine", "deepin-wine5") # 创建选择框控件
|
o1 = tk.OptionMenu(window, o1_text, "deepin-wine", "deepin-wine5") # 创建选择框控件
|
||||||
button3 = tk.Button(window, text="启动", command=runexebutton) # 创建按钮控件
|
button3 = tk.Button(window, text="启动", command=runexebutton) # 创建按钮控件
|
||||||
label4 = tk.Label(window, text="设置文件名,以便把上方填写的信息写入到 shell 文件里") # 创建标签控件
|
label4 = tk.Label(window, text="设置文件名,以便把上方填写的信息写入到 shell 文件里") # 创建标签控件
|
||||||
e3 = tk.Entry(window, textvariable=e3_text, width=100) # 创建文本框控件
|
e3 = tk.Entry(window, textvariable=e3_text, width=100) # 创建文本框控件
|
||||||
button5 = tk.Button(window, text="创建用于运行的 shell 文件到桌面", command=make_desktop_on_desktop) # 创建按钮控件
|
button5 = tk.Button(window, text="创建用于运行的 shell 文件到桌面", command=make_desktop_on_desktop) # 创建按钮控件
|
||||||
menu = tk.Menu(window) # 设置菜单栏
|
menu = tk.Menu(window) # 设置菜单栏
|
||||||
programmenu = tk.Menu(menu,tearoff=0) # 设置“程序”菜单栏
|
programmenu = tk.Menu(menu, tearoff=0) # 设置“程序”菜单栏
|
||||||
menu.add_cascade(label="程序",menu=programmenu)
|
menu.add_cascade(label="程序", menu=programmenu)
|
||||||
programmenu.add_command(label="退出程序",command=window.quit) # 设置“退出程序”项
|
programmenu.add_command(label="退出程序", command=window.quit) # 设置“退出程序”项
|
||||||
help = tk.Menu(menu,tearoff=0) # 设置“帮助”菜单栏
|
help = tk.Menu(menu, tearoff=0) # 设置“帮助”菜单栏
|
||||||
menu.add_cascade(label="帮助",menu=help)
|
menu.add_cascade(label="帮助", menu=help)
|
||||||
help.add_command(label="小提示",command=helps) # 设置“小提示”项
|
help.add_command(label="小提示", command=helps) # 设置“小提示”项
|
||||||
help.add_separator() # 设置分界线
|
help.add_separator() # 设置分界线
|
||||||
help.add_command(label="关于这个程序",command=about_this_program) # 设置“关于这个程序”项
|
help.add_command(label="程序官网", command=OpenProgramURL) # 设置“小提示”项
|
||||||
|
help.add_separator() # 设置分界线
|
||||||
|
help.add_command(label="关于这个程序", command=about_this_program) # 设置“关于这个程序”项
|
||||||
# 添加控件
|
# 添加控件
|
||||||
window.config(menu=menu) # 显示菜单栏
|
window.config(menu=menu) # 显示菜单栏
|
||||||
label1.pack()
|
label1.pack()
|
||||||
e1.pack()
|
e1.pack()
|
||||||
button1.pack()
|
button1.pack()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user