How To Load .bmp File Into Bitmapimage Class Tkinter Python
I'm unable to find any way to load .bmp file into Tkinter() so that I can use it in a canvas widget!Plz help me! from Tkinter import * from PIL import Image import ImageTk import t
Solution 1:
This works for me.
The image doesn't show when I use the Tk PhotoImage class. But it works ok when using PIL.
My image size is 50*250, so I've put coordinates that center it (25, 125)
from Tkinter import *
from PIL import Image, ImageTk
root=Tk()
root.title("My Image")
w = Canvas(root, width=50, height=250)
image = Image.open("blog0.bmp")
w.create_image((25, 125), image=ImageTk.PhotoImage(image))
w.pack()
root.mainloop()
I hope it helps
Post a Comment for "How To Load .bmp File Into Bitmapimage Class Tkinter Python"