Gui for open cv mouse event

i create a code with open cv to measure the distance between 2 points in a video that i select with mouse event but I want to create a GUI with buttons and when I did it with Tkinter the mouse event is not working on Tkinter frame anyone knows how to fix that?

yea, dont use tkinter (it’s got its very own ideas about events and the ‘main loop’)

obviously, you’re a noob, wasting time on a script, that will be forgotten 13 days later :wink:

so what i must use pygt?

yes i am but i need it for a university project

mouse events only work on windows created from cv2.imshow()
(or cv2.namedWindow())

but i cant create button with open cv

check waitKey() instead.

and seriously, – try to develop kick-ass cv algos (then you’ll be the prof !)
leave the gui nonsense to the serfs (or you’ll end up one of them …)

my university project need GUI thats why I want to create one

this site is about opencv, not about python gui

if you’re going to use Tkinter, you will need to learn how Tkinter wants mouse events to be handled, and you need to adapt your code to it.


You can use 2 layers GUI to handle the mouse event. OpenCV shows images at the bottom layer, and use a transparent GUI layer above to handle the mouse event.

that’s a good joke but I hope nobody thinks you were serious.

Why don’t you check out CVUI?