问题描述
所以我用PySimpleGUI创建了一个程序,然后用Pyinstaller从中制作了.exe文件。这是我的命令:
pyinstaller --hidden-import=pyttsx3.drivers --hidden-import=pyttsx3.drivers.dummy --hidden-import=pyttsx3.drivers.espeak --hidden-import=pyttsx3.drivers.nsss --hidden-import=pyttsx3.drivers.sapi5 -F -w -i "C:\Users\icons\logo.ico" prog.py
-F表示一个文件编
-w用于窗口应用程序(无命令提示符)
-i表示图标
顺便说一句,当我没有'-w'时,它可以正常工作,但是我想要没有cmd的应用程序
我的代码:
layout = [
[sg.Text('',size=(30,2)),sg.Text('Press "Start" button',size=(55,12),key='-MAIN-')],[sg.Button('Start',size=(10,sg.Button('Info',2))],]
window = sg.Window('App',layout,size=(800,500))
while True:
event,values = window.read()
if event == sg.WIN_CLOSED:
break
if event == 'Start':
def threading_main_process(seconds):
window['-MAIN-'].update("Starting...")
engine = pyttsx3.init()
engine.say("Hello!")
engine.runAndWait()
def search_files_thread(seconds):
for root,dirs,files in os.walk('/'):
for file in files:
if file.endswith('.mp3'):
filename = os.path.join(root,file)
threading.Thread(target = search_files_thread,args = (1,),daemon = True).start()
while True:
r = sr.Recognizer()
window['-MAIN-'].update('Say Hello')
with sr.Microphone() as source:
audio = r.listen(source)
said = ''
try:
said = r.recognize_google(audio,language="en-EN")
def threading_said(seconds):
time.sleep(10)
window['-MAIN-'].update('')
threading.Thread(target = threading_said,daemon = True).start()
except Exception as exception:
window['-MAIN-'].update(exception)
if said == 'hello':
engine.say("Hi,how are you")
engine.runAndWait()
def threading_print(seconds):
time.sleep(1)
window['-MAIN-'].update("Hi,how are you")
time.sleep(10)
window['-MAIN-'].update('')
threading.Thread(target = threading_print,daemon = True).start()
threading.Thread(target = threading_main_process,daemon = True).start()
if event == 'Info':
window['-MAIN-'].update('Press start button and say hello')
def threading_info(seconds):
time.sleep(10)
window['-MAIN-'].update('')
threading.Thread(target = threading_info,daemon = True).start()
window.close()
我收到错误消息:
'OSError: [WinError 6] The handle is invalid'
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)