1 回答

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超7個(gè)贊
這是我的解決方案:當(dāng)圖像被打開(kāi)時(shí),它會(huì)顯示 tcross 光標(biāo),當(dāng)用戶(hù)單擊時(shí)它會(huì)更改光標(biāo),直到用戶(hù)釋放。
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)
添加回答
舉報(bào)