python - 运行 tkinter 程序需要帮助
问题描述
我是 GUI 编程的新手,所以我不知道为什么当我运行这个程序时它不起作用,它没有打开 tkinter 窗口,所以请帮帮我,这只是运行语音识别程序
from tkinter import *
import speech_recognition as sr
a=1
r = sr.Recognizer()
with sr.Microphone() as source:
print("Speak Anything: ")
audio=r.listen(source)
try:
text=r.recognize_google(audio)
print("You Said : {}".format(text))
except:
print("Sorry could not recognize your voice")
root=Tk()
root.geometry("2000x700")
root.title("GUI")
root.configure(bg="#696969")
解决方案
添加 root.mainloop() 所以这肯定会工作
推荐阅读
- azure-ad-b2c - 有没有办法在 AD B2C 自定义策略中编写两个令牌发行者技术配置文件?
- php - 提交刷新问题,不使用header函数如何获取
- java - Servlet 线程处理
- php - 为什么在 7.0 之前的 PHP 上值相等时,usort 会还原数组
- list - 在颤振飞镖中合并2个对象列表的最简单方法是什么?
- plsql - Oracle Apex PL/SQL 函数 - 如果全部为空,则
- python - Keras 多输入(一个输入二进制,另一个序列)
- c# - 删除行并调整数量
- excel - 公共函数中的 VBA 运行时错误 -2147319767 (80028029)
- svelte - 当 Svelte 中的道具发生变化时如何刷新 DOM?