We know that we can resize the window of PyQt5 application, but while shrinking the window size we can set minimum size so that it can’t be shrank any more. In this article, we will see how to do this.
In order to do this we will use setMinimumSize()
method.
Syntax : self.setMinimumSize(width, height)
Argument : It takes two integer as argument.
Action performed : It sets the minimum size of window.
Code :
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import sys
class Window(QMainWindow):
def __init__( self ):
super ().__init__()
self .setWindowTitle( "Python" )
width = 200
height = 200
self .setMinimumSize(width, height)
self .label_1 = QLabel( "Minimum size" , self )
self .label_1.move( 0 , 0 )
self .label_1.setStyleSheet( "border :3px solid black;" )
self .label_1.resize( 120 , 80 )
self .show()
App = QApplication(sys.argv)
window = Window()
sys.exit(App. exec ())
|
Output :

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
26 Mar, 2020
Like Article
Save Article