Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Tkinter 中,当我在画布上创建图像并找到它的坐标时,它只返回两个坐标,因此 find_overlapping 方法(自然)不起作用。有替代方案吗?
您应该能够通过调用bbox = canvas.bbox(imageID). 然后你可以使用canvas.find_overlapping(*bbox).
bbox = canvas.bbox(imageID)
canvas.find_overlapping(*bbox)
它返回的坐标应该是图像左上角的坐标。因此,如果您获得的坐标是(x, y),并且您的图像对象(假设它是 PhotoImage)是img,那么您可以执行以下操作:
(x, y)
img
w, h = img.width(), img.height() find_overlapping(x, y, x + w, y + h)