1

I am working on the following project and I am having really difficulties in finding the right way of doing that. I would like to build in Python (but I am open to other possibilities) a very basic interface that allows the user to draw with the mouse (or the pen if used on a surface laptop) something and then save the image. Ideally I would like this to work on a website or at least in a jupyter notebook (at least I imagine this to be utterly difficult).

Anyone can point me in the right direction? The goal would be to use the images as input to a neural network model to demonstrate its result with real life examples.

I am looking at tk but I don't seem to find much in terms of examples.

Thanks in advance, Umberto

Umberto
  • 1,387
  • 1
  • 13
  • 29

3 Answers3

1

I'd take a look at pyautogui to capture the mouse location then "draw" it in matplotlib -- should be able to do this in a loop. You'll want to watch the tkinter window size to sync the mouse coordinates with the relative location.

Why not just have your script open create a new blank img and automatically open it with paint - then read it on close? Seems easier than creating a drawing GUI.

Schalton
  • 2,867
  • 2
  • 32
  • 44
1

Have a look at my Github repository which have exactly what you need.

Link : CanvasDraw Repo

Avinash Karhana
  • 659
  • 4
  • 16
0

Depending on the complexity you could either use tkinter which is a package for complex GUIs or something from the gaming community like pygames. You have user input and graphical output so libraries made for games will do what you want but provide way more stuff then you need. This site might help you: Drawing Libarys

Also the answere draw-on-python-tkinter-canvas-using-mouse-and-obtain-points-to-a-list might help you.