1 回答

TA贡献1829条经验 获得超7个赞
这是我的解决方案:当图像被打开时,它会显示 tcross 光标,当用户单击时它会更改光标,直到用户释放。
canvas.create_image(0,0,image=img,anchor="nw")
canvas.config(cursor = "tcross")
canvas.config(scrollregion=canvas.bbox(tkinter.ALL))
# function to be called when mouse is clicked
def returnCoords(event):
global cx, cy
# change the cursor when button is held / click so user knows they selected a coordinate
canvas.config(cursor = "dotbox")
cx, cy = event2canvas(event, canvas)
return cx, cy
def returnCursor(event):
canvas.config(cursor = "arrow")
time.sleep(.7)
imgApp.destroy()
# mouseclick event / release
canvas.bind("<ButtonPress-1>", returnCoords)
canvas.bind("<ButtonRelease-1>", returnCursor)
添加回答
举报