The Wayback Machine - https://web.archive.org/web/20240602165248/https://www.geeksforgeeks.org/pyqt5-how-to-stop-resizing-of-window-setfixedsize-method/
Open In App

PyQt5 – How to stop resizing of window | setFixedSize() method

Last Updated : 05 Jan, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will see how to stop resizing of the main window. While making a window, we get options like going full screen and using cursor to change its size. By using setFixedSize() method we can prevent the resizing of the image.

Syntax : self.setFixedSize(width, height) Argument : It takes two integer as argument i.e width and height. Action performed : It set the fixed size of window.

Code : 

Python3




# importing the required libraries
 
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import sys
 
 
class Window(QMainWindow):
    def __init__(self):
        super().__init__()
 
 
        # set the title
        self.setWindowTitle("Python")
 
        width = 500
        height = 400
        # setting  the fixed size of window
        self.setFixedSize(width, height)
 
        # creating a label widget
        self.label_1 = QLabel("Fixed size window", self)
 
        # moving position
        self.label_1.move(100, 100)
 
        # setting up the border
        self.label_1.setStyleSheet("border :3px solid black;")
 
        # resizing label
        self.label_1.resize(120, 80)
 
        # show all the widgets
        self.show()
 
 
# create pyqt5 app
App = QApplication(sys.argv)
 
# create the instance of our Window
window = Window()
 
# start the app
sys.exit(App.exec())


Output : pyqt-stop-resize-window



Similar Reads

PYGLET – Setting Size / Resizing of Window
In this article we will see how we can set the size of the window in PYGLET module in python. Pyglet is easy to use but powerful library for developing visually rich GUI applications like games, multimedia etc. A window is a "heavyweight" object occupying operating system resources. Windows may appear as floating regions or can be set to fill an en
2 min read
Dynamically Resize Buttons When Resizing a Window using Tkinter
Prerequisite: Python GUI – tkinter Button size is static, which means the size of a button cannot be changed once it is defined by the user. The problem here is while resizing the window size, it can affect the button size problem. So the solution here is, make a dynamic button, which means the button size will change as per window size. Let's unde
2 min read
Allowing resizing window in PyGame
In this article, we will learn How to allow resizing a PyGame Window. Game programming is very rewarding nowadays and it can also be used in advertising and as a teaching tool too. Game development includes mathematics, logic, physics, AI, and much more and it can be amazingly fun. In python, game programming is done in pygame and it is one of the
2 min read
PyQt5 QSpinBox - Resizing it according to value
In this article we will see how we can resize the spin box according to its value. We can set the dimension of the spin box with the help of setGeometry method although it takes position argument as well therefore resizing it is not appropriate. In order to do this we use resize method with the spin box object. Syntax : spin_box.resize(width, heigh
2 min read
Image Resizing in Matlab
Prerequisite : RGB image representation MATLAB stores most images as two-dimensional matrices, in which each element of the matrix corresponds to a single discrete pixel in the displayed image. Some images, such as truecolor images, represent images using a three-dimensional array. In truecolor images, the first plane in the third dimension represe
2 min read
Image Resizing using OpenCV | Python
Image resizing refers to the scaling of images. Scaling comes in handy in many image processing as well as machine learning applications. It helps in reducing the number of pixels from an image and that has several advantages e.g. It can reduce the time of training of a neural network as the more the number of pixels in an image more is the number
2 min read
Mahotas - Resizing Image
In this article we will see how we can resize the image in mahotas. Image interpolation occurs when you resize or distort your image from one pixel grid to another. Image resizing is necessary when you need to increase or decrease the total number of pixels, whereas remapping can occur when you are correcting for lens distortion or rotating an imag
2 min read
MoviePy – Resizing Video File
In this article, we will see how we can resize video file clips in MoviePy. MoviePy is a Python module for video editing, which can be used for basic operations on videos and GIF's. Resizing video files means. Image/frame interpolation occurs when you resize or distort your frame of video from one-pixel grid to another. Video resizing is necessary
3 min read
Image resizing using Seam carving using OpenCV in Python
Seam carving is an effective image processing technique with the help of which an image can be resized without removing important elements from the image. The basic approach is to find all the continuous pixels with low energy from left to right or from top to bottom. After the region is selected, it is removed from the original image, leaving only
2 min read
Python OpenCV - Bicubic Interpolation for Resizing Image
Image resizing is a crucial concept that wishes to augment or reduce the number of pixels in a picture. Applications of image resizing can occur under a wider form of scenarios: transliteration of the image, correcting for lens distortion, changing perspective, and rotating a picture. The results of resizing greatly vary looking on the kind of inte
9 min read
Article Tags :
Practice Tags :