Thursday, October 2, 2025
HomeLanguagesPyQt5 – How to open window in maximized format?

PyQt5 – How to open window in maximized format?

In this article we will see how to make a window to open in maximized format, which refer to full screen display window. We can do this by using showMaximized method which belongs to QWidget class.

Syntax : self.showMaximized()

Argument : It takes no argument.

Action performed It will open the window in full screen format.

Code :




# importing libraries
from PyQt5.QtWidgets import * 
from PyQt5.QtGui import * 
from PyQt5.QtCore import * 
import sys
  
  
class Window(QMainWindow):
    def __init__(self):
        super().__init__()
  
        # setting title
        self.setWindowTitle("Python ")
  
        # setting geometry
        self.setGeometry(100, 100, 600, 400)
  
        # calling method
        self.UiComponents()
  
        # showing all the widgets
        self.show()
  
    # method for widgets
    def UiComponents(self):
  
        # creating label
        label = QLabel("Label", self)
  
        # setting geometry to label
        label.setGeometry(100, 100, 120, 40)
  
        # adding border to label
        label.setStyleSheet("border : 2px solid black")
  
        # opening window in maximized size
        self.showMaximized()
  
  
# create pyqt5 app
App = QApplication(sys.argv)
  
# create the instance of our Window
window = Window()
  
# start the app
sys.exit(App.exec())


Output :

RELATED ARTICLES

Most Popular

Dominic
32331 POSTS0 COMMENTS
Milvus
85 POSTS0 COMMENTS
Nango Kala
6703 POSTS0 COMMENTS
Nicole Veronica
11867 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11926 POSTS0 COMMENTS
Shaida Kate Naidoo
6818 POSTS0 COMMENTS
Ted Musemwa
7079 POSTS0 COMMENTS
Thapelo Manthata
6775 POSTS0 COMMENTS
Umr Jansen
6776 POSTS0 COMMENTS