I have a main window with three frames.The top frame consists of the header and the bottom frame consists of the footer. I designed it using the PyQt4
designer.The window looks fine when I run it on my laptop with a screen resolution of 1920*1080
. But when I check the same on other resolutions like 1600*900
the footer gets cut off. I wanted to know if there is a way to resize the window according to screen resolution in the runtime so that all the three frames are shown. I tried to check online if there are any solutions for this but could not find any. I tried using window.setGeometry
and window.setFixedSize
functions,but it did not work.
The code for the window is:
import sys
import os
import threading
import smtplib
from PyQt4 import QtCore, QtGui, uic
import sched
import time
form_class = uic.loadUiType("FirstTest.ui")[0] # Load the UI
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s
class MyWindowClass(QtGui.QMainWindow, form_class):
def __init__(self, parent=None):
QtGui.QMainWindow.__init__(self, parent)
self.setupUi(self)
#has some code for the field values to be shown
app = QtGui.QApplication(sys.argv)
myWindow = MyWindowClass(None)
#myWindow.setFixedSize(500,500)
myWindow.showMaximized()
palette = QtGui.QPalette()
palette.setColor(QtGui.QPalette.Background,QtCore.Qt.white)
myWindow.setPalette(palette)
myWindow.show()
app.exec_()
By using setFizedSize() method we can prevent the resizing of the image. Argument : It takes two integer as argument i.e width and height. Action performed : It set the fixed size of window.
You can use
showFullScreen() or just showMaximized()
and you can get screen geometry with:
desktop() and screenGeometry()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With