Python Forum
how do i find the canvas location of an object?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how do i find the canvas location of an object?
#1
while i try to get the canvas or even the bbox coordinates of an object i am either getting None returned or the object is returning the memory location of the object and not the location on the canvas,

from tkinter import *
from PIL import ImageTk,Image
root = Tk()
canvas=Canvas(root,width=400,height=400)
canvas.pack()

class Image:
    def __init__(self):
        self.img = PhotoImage(file='./8bitship.png')
        self.id =  canvas.create_image(120,0,anchor=NW,image=self.img)

mship = Image()

mship_loc = canvas.bbox(mship)
print(mship_loc)
print(mship)
Reply


Messages In This Thread
how do i find the canvas location of an object? - by gr3yali3n - Mar-03-2021, 02:08 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Resizing image inside Canvas (with Canvas' resize) Gupi 2 25,160 Jun-04-2019, 05:05 AM
Last Post: Gupi
  [Tkinter] Problem loading an image from directory into a Canvas object tiotony 3 3,896 Sep-02-2018, 06:47 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