[Tutor] Python Image Library
mysecretrobotfactory at gmail.com
Wed May 17 18:33:26 EDT 2017
Actually, that is the whole script! I didn't get used to have the cmd.exe
window pop up at all, could it be something I did?
Or, is there a way to suppress that from showing up?
On Wed, May 17, 2017 at 3:30 PM, eryk sun <eryksun at gmail.com> wrote:
> On Wed, May 17, 2017 at 8:24 PM, Michael C
> <mysecretrobotfactory at gmail.com> wrote:
> > from PIL import Image
> > im = Image.open('pic.bmp')
> > im.show()
> > I ran this code and it not only opened the picture in paint, which is
> > I want, but it also opens a CMD.exe console window! how do I prevent
> that from
> > happening?
> You're probably running a .py script that's associated with py.exe or
> python.exe. These executables create a new console (i.e. an instance
> of the console host process, conhost.exe), if they don't inherit one
> from their parent process. The new console defaults to creating a
> visible window. Change the file extension to .pyw. This file extension
> should be associated with pyw.exe or pythonw.exe, which will not
> create a console.
> FYI, the cmd shell is unrelated to that console window. Windows users
> often confuse the cmd shell with the console window that it uses. I
> suppose it's less confusing on Linux. Like cmd, bash will inherit the
> parent's terminal/console; however, it doesn't automatically spawn a
> terminal on Linux if the parent doesn't have one. (Getting that
> behavior on Windows requires the DETACHED_PROCESS creation flag.)
> Since Windows users typically run cmd.exe to get a command-line shell
> for running programs, they associate cmd.exe with the console window.
> It isn't obvious that other programs create consoles without any
> associated instance of cmd.exe.
More information about the Tutor