# Creating a mouse interaction app in Hugging Face

**URL:** <https://discuss.huggingface.co/t/creating-a-mouse-interaction-app-in-hugging-face/36526>\
**Category:** 🔒 Gradio\
**Created:** [April 14, 2023, 2:43am UTC](https://discuss.huggingface.co/t/creating-a-mouse-interaction-app-in-hugging-face/36526 "2023-04-14T02:43:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JunchuanYu](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/junchuanyu/32/15315_2.png) [@JunchuanYu](https://discuss.huggingface.co/u/JunchuanYu)\
**Post date:** [April 14, 2023, 2:43am UTC](https://discuss.huggingface.co/t/creating-a-mouse-interaction-app-in-hugging-face/36526/1 "2023-04-14T02:43:15Z")

</div>

I want to implement interactive point selection using the mouse in gradio.image and display the coordinates in real-time on the image. Is there any way to achieve this? Here is my code: # Used to implement interactive point selection and display the image coordinates of the point in real-time.  
I have already built a similar function in my local environment, but I want to implement it on Hugging Face.

def onclick(event):

```
ax.clear()
ax.imshow(image)
ax.scatter(event.xdata, event.ydata, s=100, color='red')
plt.draw()
x_slider.value = event.xdata
y_slider.value = event.ydata
pointx.append(x_slider.value)
pointy.append(y_slider.value)
print(pointx)

```

# Update the position of the point when slider values are changed

def on\_value\_change(change):  
ax.clear()  
ax.imshow(image)  
ax.scatter(x\_slider.value, y\_slider.value, s=100, color=‘red’)  
# plt.draw()

%matplotlib widget  
pointx=  
pointy=  
fig, ax = plt.subplots(figsize=(8,6))  
ax.imshow(image)  
plt.axis(‘off’)

# Initialize the slider variables with the coordinates of the center of the picture

x\_slider = widgets.FloatSlider(min=0, max=image.shape[1], step=1,description=‘X:’, value=image.shape[1] // 2)  
y\_slider = widgets.FloatSlider(min=0, max=image.shape[0], step=1,description=‘Y:’, value=image.shape[0] // 2)  
x\_slider.observe(on\_value\_change, names=‘value’)  
y\_slider.observe(on\_value\_change, names=‘value’)  
cid = fig.canvas.mpl\_connect(‘button\_press\_event’, onclick)

---

<div class="post-metadata">

**Author:** ![alamdarkhalid](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@alamdarkhalid](https://discuss.huggingface.co/u/alamdarkhalid)\
**Post date:** [September 20, 2023, 10:24am UTC](https://discuss.huggingface.co/t/creating-a-mouse-interaction-app-in-hugging-face/36526/2 "2023-09-20T10:24:27Z")

</div>

Thank you so much for sharing these type of information related to mouse, so if any one check his mouse speed then click on [mouse speed](https://clicktester.net/)
