Skip to content
Related Articles

Related Articles

PyQt5 – How to create semi transparent window ?

View Discussion
Improve Article
Save Article
  • Last Updated : 26 Mar, 2020

When we design an application in PyQt5, the main window is used to appear by default the window is opaque, but we can make it transparent as well. we can do this by using setWindowOpacity() method which belongs to the QWidget class.

Syntax : setWindowOpacity(0.5)

Argument : It takes float value as argument : 0 for completely transparent and 1 for opaque.

Action performed : Makes the window transparent.

Code :

# importing the required libraries
from PyQt5.QtCore import * 
from PyQt5.QtGui import * 
from PyQt5.QtWidgets import * 
import sys
class Window(QMainWindow):
    def __init__(self):
        # set the title
        # setting  the geometry of window
        self.setGeometry(60, 60, 600, 400)
        # creating a label widget
        self.label_1 = QLabel("transparent ", self)
        # moving position
        self.label_1.move(100, 100)
        # show all the widgets
# create pyqt5 app
App = QApplication(sys.argv)
# create the instance of our Window
window = Window()
# start the app

Output :

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!