[Tutor] Python Image Library

Alan Gauld alan.gauld at yahoo.co.uk
Thu May 18 13:06:35 EDT 2017


On 18/05/17 16:43, Michael C wrote:
> os.startfile('1.bmp')
> 
> works like a charm!
> 
> Now I need to figure out how to close this window once I finish with it!

Sadly that is manual. Unless you care to write code to search for the
process and use the Windows API to kill it off.

If you really want the image under your programs control you
need to build a GUI, even if a very basic one and display
the image in a window. A very simplistic Tkinter app will
do for simply splatting an image on screen then closing
it later. But it all depends what else you need the app to
do how complex it gets after that.

Here is some untested Tkinter code to display an image
for 2 seconds:

import tkinter as tk

top = tk.Tk()
tk.Label(top, image='1.bmp').pack()
top.after(2000, top.quit)

top.mainloop()

If not that, something quite like it...

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list