首页 > 解决方案 > Python 脚本没有响应

问题描述

(我是一个关于编程的初学者)我编写了一个 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()

我只是忘记了一个循环吗?(但我已经有一个循环,那么我该怎么做呢?)或者它是完全不同的东西?

在此先感谢(也很抱歉没有将代码作为示例代码)

标签: python

解决方案


你检查你的目录是否存在你的文件?


推荐阅读