w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Python Tkinter - How to display JPG image in Button

After looking around a bit, here's what I got. I haven't tested this, though.

from PIL import Image, ImageTk

image = Image.open("mypic.jpg")
photo = ImageTk.PhotoImage(image)

Button(...,image=photo,command=myfunc)

The foto should be image here. PIL is a dependency you have to obtain. Hope this helps.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.