Python OpenCV - destroyAllWindows() Function Last Updated : 03 Jan, 2023 Comments Improve Suggest changes Like Article Like Report Python Opencv destroyAllWindows() function allows users to destroy or close all windows at any time after exiting the script. If you have multiple windows open at the same time and you want to close then you would use this function. It doesn't take any parameters and doesn't return anything. It is similar to destroyWindow() function but this function only destroys a specific window unlike destroyAllWindows(). Example 1: Closing window using destroyWindow() function In the Python script given below, we have created two windows named 'P' and 'Q' respectively that displayed an image of "gfg_logo.png" using the cv2.imshow() function that is supposed to display window 'P' first on the screen but before calling the waitKey() function to delay the closing of windows, we will destroy only the window named 'P' with destroyWindow('P') function by passing the window name 'P' as its argument. We will see that the window 'Q' is only displayed on the screen which will close only when the user closes it. Python # importing cv2 module import cv2 # read the image img = cv2.imread("gfg_logo.png") # showing the images cv2.imshow('P', img) cv2.imshow('Q', img) # Destroying the window named P before # calling the waitKey() function cv2.destroyWindow('P') # using the wait key function to delay the # closing of windows till any key is pressed cv2.waitKey(0) Output: Example 2: Closing window using destroyAllWindows() function In this case, instead of calling destroyWindow() to delete or close a particular window, we will use destroyAllWindows() to destroy all windows on the screen here we have called this function before waitKey(0), so the images will not at all displayed on the screen. DestroyAllWindows() is just a good coding practice. Python # importing cv2 module import cv2 # read the image img = cv2.imread("gfg_logo.png") # showing the images cv2.imshow('P', img) cv2.imshow('Q', img) # Destroying All the windows cv2.destroyAllWindows() # using the wait key function to delay # the closing of windows till any key is pressed cv2.waitKey(0) Output: Comment More infoAdvertise with us Next Article Python OpenCV - destroyAllWindows() Function Y yashgupta0524 Follow Improve Article Tags : Python OpenCV Python-OpenCV Practice Tags : python Similar Reads Python OpenCV - destroyWindow() Function Python Opencv destroyWindow() function is used to close particular windows. This function takes one parameter that is window name which you want to close or destroy and it doesn't return anything. Syntax: cv2.destroyWindow(window_name) Parameter: window_name: name of the window which you want to des 1 min read Python OpenCV - waitKey() Function waitkey() function of Python OpenCV allows users to display a window for given milliseconds or until any key is pressed. It takes time in milliseconds as a parameter and waits for the given time to destroy the window, if 0 is passed in the argument it waits till any key is pressed. Example: Pythonim 2 min read Python OpenCV - namedWindow() Function Python OpenCV namedWindow() method is used to create a window with a suitable name and size to display images and videos on the screen. The image by default is displayed in its original size, so we may need to resize the image for it to fit our screen. Created windows are referred by their names and 3 min read Python OpenCV - waitKeyEx() Function Python OpenCv waitKeyEx() method is similar to waitKey() method but it also returns the full key code. The key code which is returned is implementation-specific and depends on the used backend: QT/GTK/Win32/etc. Syntax: cv2.waitKey(delay) Parameters: delay: The time in milliseconds after which windo 2 min read Python OpenCV - moveWindow() Function When we show the image using the imshow() function output window will open at the center or default position of a computer screen. Even if there are multiple image windows all windows will be displayed at the same position and we have to move windows manually. If we want to show image windows at a s 2 min read Python OpenCV - resizeWindow() Function resizeWindow() method in Python OpenCV is used to resize window displaying images/videos to a specific size. The specified window size is for images excluding toolbars. This only works for created windows having flags other than CV_WINDOW_AUTOSIZE. Syntax: cv2.resizeWindow(window_name, width, height 1 min read Python OpenCV - getWindowImageRect() Function Python OpenCV getWindowImageRect() Function returns the client screen coordinates, along with the width and height of the window containing the picture. Syntax of cv2.getWindowImageRect() Syntax: cv2.getWindowImageRect(window_name) Parameter:Â window_name - Name of the window displaying image/video 3 min read wxPython - Destroy button widget using Destroy() function In this article we will learn that, how can we destroy a button widget from a window using Destroy() function in wx.Button class of wxPython. Destroy() function is used to simply destroy a window or widget safely. Destroy() returns True if the window has either been successfully deleted, or it has b 2 min read Handle mouse events in Python - OpenCV OpenCV is one of the most popular computer vision libraries. If you want to start your journey in the field of computer vision, then a thorough understanding of the concepts of OpenCV is of paramount importance. Note: For more information, refer to Introduction to OpenCV Handling Mouse Evenets OpenC 2 min read Like