查找tkinter图像的所有坐标

问题描述 投票:0回答:1

我正在尝试查找tkinter图像的所有坐标(x1,x2,y1,y2)。当我使用canvas.coords函数时,它将返回2个坐标。我已经尝试过canvas.bbox函数,但返回的内容与canvas.coords相同。一个例子可能是:

from tkinter import *

root = Tk()
root.title('Test')
root.resizable(0, 0)

canvas = Canvas(root, width=500, height=500, bd=0, highlightthickness=0)
canvas.pack()

image = PhotoImage(file='image.png')
id = canvas.create_image(250, 250, anchor='c', image=image)
coords = #coordinate function to get 4 coords
print(coords)
python tkinter
1个回答
-1
投票

您正在以某种方式更新坐标。当您执行bbox时,它以某种方式更新为coords

© www.soinside.com 2019 - 2024. All rights reserved.