Closed frank572 closed 5 years ago
Link to the aforementioned StackOverflow question: https://stackoverflow.com/q/57381005/652722
Further clarification: I wrote an earlier interactive version of the app without tkinter. Went back to check, and in fact the issue is the same so it may be a python issue rather than tkinter. What I found:
Without pyttsx3:
With pyttsx3:
Again, all that's required to disable the app is the import statement itself.
My Windows tkinter app will run console-free (.pyw) until I import pyttsx3. As soon as pyttsx3 is imported, the app will only run from the editor (Idle). I have determined that the import statement alone is enough to cause this.
import tkinter as tk (runs fine in .pyw mode)
import tkinter as tk import pyttsx3 as speak (will run fine in Idle, but will not run in .pyw mode)
The question: how could simply importing a library (not even initializing or using it...just importing it) cause the tkinter app to no longer run as .pyw? Could importing a library somehow be interfering with the tkinter main loop?
I received this response on StackOverflow, which suggested I post on this forum:
Good question. If I had to guess, something in the pyttsx3 library calls a subprocess that is unrelated to Python, for the purpose of text-to-speech conversion. Windows probably opens a Command Prompt window in such a case since that program is unaffected by Python runtime information.
Unless the pyttsx3 library has documentation for how to suppress this—after a cursory glance, I don't see such—then I would recommend opening a new issue with the package maintainer. I believe that it would need to set the CREATE_NO_WINDOW flag when being run on Windows.