如何在没有tkinter gui冻结的情况下执行命令
我一直在研究GUI,我需要执行的一个命令是ngrok.exe。但是,每当我使用os.System(f“ ngrok.exe http -basic-auth {base_creds} file://// mal_files”)
它会冻结GUI和不继续工作。有什么方法可以解决此问题吗?我听说线程可能会有所帮助,但我对它们一无所知。
代码
def start_ngrok():
ngrok_creds = open("tools/ngrok_creds.txt", "r")
ngrok_creds_lines = ngrok_creds.readlines()
base_creds = ngrok_creds_lines[0]
ngrok_creds.close()
try:
os.system(f"ngrok.exe http --basic-auth {base_creds} file:///Mal_Files")
ngrok_started_q = True
except:
print("Error staring ngrok server, try again later.")
ngrok_started_q = False
os.kill
# Button to start ngrok code
run_ngrok = tkinter.Button(base_frame, text="Start Ngrok",command=Main.start_ngrok, width=20)
base_frame.create_window(80, 20, window=run_ngrok)
I've been working on a GUI, and one command I need to execute is ngrok.exe. But whenever I use os.system(f"ngrok.exe http --basic-auth {base_creds} file:///Mal_Files")
it freezes the GUI and wont continue working. Is there any way to fix this? I've heard threads could help but i dont know anything about them.
CODE
def start_ngrok():
ngrok_creds = open("tools/ngrok_creds.txt", "r")
ngrok_creds_lines = ngrok_creds.readlines()
base_creds = ngrok_creds_lines[0]
ngrok_creds.close()
try:
os.system(f"ngrok.exe http --basic-auth {base_creds} file:///Mal_Files")
ngrok_started_q = True
except:
print("Error staring ngrok server, try again later.")
ngrok_started_q = False
os.kill
# Button to start ngrok code
run_ngrok = tkinter.Button(base_frame, text="Start Ngrok",command=Main.start_ngrok, width=20)
base_frame.create_window(80, 20, window=run_ngrok)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论