首页 > 解决方案 > 运行 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")

标签: pythonuser-interfacetkinter

解决方案


添加 root.mainloop() 所以这肯定会工作


推荐阅读