Ask Your Question
0

Disable X close button of cv2.window

asked 2020-11-10 03:01:49 -0500

aroman gravatar image

updated 2020-11-10 07:51:48 -0500

I m displaying certain frames from a microscope in a cv2.window ( in Python) but problems could appear if the users try to close the window i Is there any way to disable or hide the X close button in the right top corner from a cv2.window, or at least changing its behavior so nothing happens with the window when clicked?

PS: I am using Windows 10, Python 3.6 and OpenCV 4.3.0 image description

edit retag flag offensive close merge delete

Comments

Do u meant close window or grayed out X button?

supra56 gravatar imagesupra56 ( 2020-11-10 04:53:39 -0500 )edit
1

I want to grey out or disable or make disappear the X button in the right corner of the window when the video is displaying

aroman gravatar imagearoman ( 2020-11-10 06:38:54 -0500 )edit

Not in OpenCV. U can do in GUI such as python, Qt, etc.

supra56 gravatar imagesupra56 ( 2020-11-10 08:34:10 -0500 )edit
1

but if I try to close the window with the button the window will remain always open? it can be only closed with keys via waitkey?

aroman gravatar imagearoman ( 2020-11-10 09:30:37 -0500 )edit

This will close window. Put this at the bottomcv2.destroyAllWindows()

supra56 gravatar imagesupra56 ( 2020-11-10 15:35:52 -0500 )edit

Example, When u press q on keyboard. It will close window.:

    cv2.imshow('frame',gray)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
supra56 gravatar imagesupra56 ( 2020-11-10 21:18:57 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-11-14 07:51:01 -0500

berak gravatar image

Is there any way to disable or hide the X close button in the right top corner

NO. if you think it's annoying, use a different gui

will remain always open?

each new imshow() call will re-open it

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-11-10 03:01:49 -0500

Seen: 665 times

Last updated: Nov 14 '20