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)
添加回答
舉報