Python code:
from tkinter import *
from PIL import Image, ImageTk
import cv2
root = Tk()
labelFrame =Frame(root,width=10,height=10)
labelFrame.grid(row=0, column=0)
img=cv2.imread("md_5aba147bcacf2.png")
cv2.imwrite("md_5aba147bcacf2.png",img)
photo=PhotoImage(file="md_5aba147bcacf2.png")
label=Label(labelFrame,image=photo)
label.grid(row=1, column=1)
# Determine the origin by clicking
def getorigin(eventorigin):
global x0,y0
x0 = eventorigin.x
y0 = eventorigin.y
print(x0,y0)
#mouseclick event
label.bind("<Button 1>",getorigin)
root.mainloop()
No comments:
Post a Comment