Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Python 2.7とTkinterを使用して、クリックすると関数が実行される画像を作成するにはどうすればよいですか? 私は次のようなものを使用することを考えていました
Button(...,foto = "mypic.jpg",command=myfunc)
しかし、私は管理しません。
あなたの助けは大歓迎です!
ちょっと調べてみたら、こんなのがありました。ただし、これはテストしていません。
from PIL import Image, ImageTk image = Image.open("mypic.jpg") photo = ImageTk.PhotoImage(image) Button(...,image=photo,command=myfunc)
はここfotoにあるはずimageです。PIL取得する必要がある依存関係です。お役に立てれば。
foto
image
PIL