[Tkinter] Bitmap Image Class

johngrayson42 johngrayson at home.com
Sun Feb 17 09:57:05 EST 2002


Try this...

from Tkinter import *

root = Tk()

lbl = Label(root)
bmp = BitmapImage(file="bitmap.bmp")
lbl.config(image=bmp)
lbl.pack()

root.mainloop()

  ...if you want to maintain your structure...

This:

...
bmp = BitmapImage(file="bitmap.bmp")
Label(root, image=bmp).pack()
...

  ...if you're into brevity.

===================================================

Before anyone tries it and asks the question "why don't
I see an image?" DO NOT TRY ANY VARIANTS OF THIS:

Label(root, image=BitmapImage(file="bitmap.bmp")).pack()

  ... you MUST keep a reference to the bitmap around...

===================================================

      John Grayson






More information about the Python-list mailing list