Python Forum
[Tkinter] Why is it so difficult to just ouput an image where I want?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Why is it so difficult to just ouput an image where I want?
#6
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 :-)
Reply


Messages In This Thread
RE: Why is it so difficult to just ouput an image where I want? - by wuf - Apr-05-2019, 01:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Switching from tkinter to gtk is difficult! snakes 1 1,505 Aug-08-2022, 10:35 PM
Last Post: woooee

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020