(Apr-05-2019, 01:19 PM)wuf Wrote: Hi jpezz
You have to bind the tk-image to an object. In your case for instance to the object root. The canvas needs a layout membership for which i choosed pack. For the canvas.create_image add for instance the option anchor='nw'. So the x/y-coordinates relate to the upper left corner of the image. In your case the image would be place outsite of the visuable surface of the canvas:
from Tkinter import * from PIL import Image, ImageTk root = Tk() # Remove titlebar #root.overrideredirect(1) canvas = Canvas(root, width =200,height=200) canvas.pack() image = Image.open("pngs/a.jpg") #logo=PhotoImage(file="pngs/a.jpg) root.logo = ImageTk.PhotoImage(image) canvas.create_image(10, 10, image=root.logo, anchor='nw') root.mainloop()wuf :-)
I got it! I misunderstood the coordinates in the canvas.create_image statement. I thought it was the POSITION of the canvas in the window. Instead I was locating the image outside the canvas. However, I would like to position the canvas in a specific location. I found nothing on that but did find something on Label so I tried this:
canvas.place(x=50,y=100)but it doesn't work. How can I position the canvas itself on the screen?