Tkinter Canvas Insert Image
You can use create_image( ) within the Canvas control to insert an image file inside the Canvas object, which has the following syntax.
create_image(x, y, options)
(x,y) is the position of the top left corner of the image, the following are the common usage of options.
(1) anchor
: default is anchor=CENTER.
(2) image
: the inserted image.
Example#1
Insert the image file apidemos-2.png, this program will create the window with the x-axis 30 pixels greater than the image width and the y-axis 20 pixels greater than the image height.
from tkinter import *
from PIL import Image, ImageTk
tk = Tk()
tk.title("apidemos.com")
img = Image.open("apidemos-2.png")
myPic = ImageTk.PhotoImage(img)
canvas = Canvas(tk, width=img.size[0]+40,
height=img.size[1]+30, bg='yellow')
canvas.create_image(200,15,anchor=NW,image=myPic)
canvas.pack(fill=BOTH,expand=True)
tk.mainloop()
Output: