(我是编程方面的初学者) 我已经编写了一个Python GUI来运行批处理文件,这些文件可以在本地Steam服务器上的CSGO中激活不同的游戏模式。当我运行脚本时,一切正常,但是执行命令后,程序不再响应。
import tkinter as tk
import subprocess
def startA():
subprocess.call([r'D:\CSGO_server\Arms_race.bat'])
def startCa():
subprocess.call([r'D:\CSGO_server\Casual.bat'])
def startCo():
subprocess.call([r'D:\CSGO_server\Competitive.bat'])
def startDea():
subprocess.call([r'D:\CSGO_server\Deathmatch.bat'])
def startDem():
subprocess.call([r'D:\CSGO_server\Demolition.bat'])
def startQ():
subprocess.call([r'D:\CSGO_server\Quit.bat'])
root = tk.Tk()
root.title("Settings")
frame = tk.Canvas(root)
frame.pack()
Armsrace = tk.Button(frame,
text="Arms_race",
fg="red",
command=startA)
Armsrace.pack(side=tk.BOTTOM)
Casual = tk.Button(frame,
text="Casual",
fg="red",
command=startCa)
Casual.pack(side=tk.BOTTOM)
Competitive = tk.Button(frame,
text="Competitive",
fg="red",
command=startCo)
Competitive.pack(side=tk.BOTTOM)
Deathmatch = tk.Button(frame,
text="Deathmatch",
fg="red",
command=startDea)
Deathmatch.pack(side=tk.BOTTOM)
Demolition = tk.Button(frame,
text="Demolition",
fg="red",
command=startDem)
Demolition.pack(side=tk.BOTTOM)
Stop = tk.Button(frame,
text="Stop Server",
fg="red",
command=startQ)
Stop.pack(side=tk.BOTTOM)
root.mainloop()
我刚开始循环吗?(但是我已经在那里循环了,那我该怎么做呢?) 还是完全不同?
预先感谢 (也很抱歉没有将代码作为示例代码)
答案 0 :(得分:0)
您是否检查目录是否存在文件?