Python 3.5.2
我正在尝试从canvas.create_image
与另一个canvas.create_image
重叠时获得输出。当我尝试canvas.find_overlapping
时收到错误消息:ValueError: not enough values to unpack (expected 4, got 2)
代码如下:
finish = canvas.create_image(100, 200, image=img2, anchor='nw')
img = canvas.create_image(100, 100, image=img1, anchor='nw')
def checkfinish():
x1, y1, x2, y2 = canvas.coords(img)
result = canvas.find_overlapping(x1, y1, x2, y2)
if finishline in result:
print('overlaps')
root.after(250, checkfinish)
注意:canvas,img1等。已经定义,这只是相关代码。
谢谢
答案 0 :(得分:1)
我的猜测是您需要图像的边界框,而不是坐标。将checkfinish
中的第一行更改为:
x1, y1, x2, y2 = canvas.bbox(img)