python 获取鼠标在图片上的坐标 10
请问如何能够在python中实现,加载图片,然后用鼠标点击图片上的某个点,返回鼠标此刻在图片上的坐标?...
请问如何能够在python中实现,加载图片,然后用鼠标点击图片上的某个点,返回鼠标此刻在图片上的坐标?
展开
展开全部
下pygame module,然后
import pygame
pygame.init()
screen = pygame.display.set_mode([100,100]) ##size of window
your_image = pygame.image.load("your_image_name.png") ## image must be in the same folder, else path must be specified
while 1:
screen.blit(your_image,[0,0]) ##pos of your image on the window
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
position = pygame.mouse.get_pos() ##position of mouse on window
print position
pygame.display.set_caption(str(position)) ##make it the title of the window
pygame.display.flip()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询