PyQt5 – How to open window in maximized format?
Last Updated :
22 Apr, 2020
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 :
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys
class Window(QMainWindow):
def __init__( self ):
super ().__init__()
self .setWindowTitle( "Python " )
self .setGeometry( 100 , 100 , 600 , 400 )
self .UiComponents()
self .show()
def UiComponents( self ):
label = QLabel( "Label" , self )
label.setGeometry( 100 , 100 , 120 , 40 )
label.setStyleSheet( "border : 2px solid black" )
self .showMaximized()
App = QApplication(sys.argv)
window = Window()
sys.exit(App. exec ())
|
Output :
Share your thoughts in the comments
Please Login to comment...