Comment ajouter une image dans Tkinter
from tkinter import *
root=Tk()
img=PhotoImage(file='sunshine.jpg')
Label(root,image=img).pack()
root.mainloop()
Krypton 36
from tkinter import *
root=Tk()
img=PhotoImage(file='sunshine.jpg')
Label(root,image=img).pack()
root.mainloop()
from tkinter import *
from PIL import ImageTk, Image
root = Tk()
c = Canvas(root, width=500, height=500)
c.pack()
img = ImageTk.PhotoImage(Image.open(r"imagepath\imagename.extension"))
c.create_image(x, y, image=img, anchor=NW)
pip install Pillow
import tkinter
from PIL import Image, ImageTk
load= Image.open("/Users/omprakash/Desktop/Gmail-new-logo.jpg")
render = ImageTk.PhotoImage(load)
img = Label(root, image=render)
img.place(x=100, y=100)
import tkinter as tk
window = tk()
canvas = Canvas(window, width=300, height=300)
image = PhotoImage('path')
canvas.create_image(height=40, width=40, img=image)
import tkinter
from tkinter import *
from PIL import Image, ImageTk
root = Tk()
# Position text in frame
Label(root, text = 'Position image on button', font =('<font_name>', <font_size>)).pack(side = TOP, padx = <x_coordinate#>, pady = <y_coordinate#>)
# Create a photoimage object of the image in the path
photo = PhotoImage(file = "</path/image_name>")
# Resize image to fit on button
photoimage = photo.subsample(1, 2)
# Position image on button
Button(root, image = photoimage,).pack(side = BOTTOM, pady = <y_coordinate#>)
mainloop()