Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Python OpenCV – setWindowTitle() Function

  • Last Updated : 17 Oct, 2021

Python OpenCV setWindowTitle() method used for giving the title of the windows. It takes 2 parameters that are windows name and the title that needs to be given. Both the parameters are expected to be of string type.

Syntax: cv2.setWindowTitle( winname, title ) 

Parameters:

  • winname: windows name
  • title: title we want to set for the window with the above name.

Example of Python OpenCV setWindowTitle() methods

Here we will see an example code. We have a png image of gfg logo with the name “gfg_logo.png” and for this example, we will display it on a window using imread() and imshow() methods of OpenCV. We will change the Windows title from the default name to “Hello!” using the setWindowTitle() method. We will pass the parameters windows name which is “gfg” and the title we want to set as parameters.

Python




# importing cv2 module
import cv2
  
# read the image
img = cv2.imread("gfg_logo.png")
  
# showing the image
cv2.imshow('gfg', img)
  
# Setting the windows title to "Hello!"
# using setWindowTitle method
cv2.setWindowTitle('gfg', 'Hello!')
  
# waiting using waitKey method
cv2.waitKey(0)

Output:

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!