[PyQt] Simple Window Problem

David Cortesi davecortesi at gmail.com
Sun Mar 22 17:53:16 GMT 2015


> The window opens taking the full size of the screen even though I set it
> up to use a smaller size on the PI. Additionally, the top line of the
> window is missing. I have found no way, that works, to reduce the size
> of the screen.
>

Interesting. I always find the proper use of the pyuic5 output confusing,
despite the relatively clear documentation here:

http://pyqt.sourceforge.net/Docs/PyQt5/designer.html

You appear to be using the "second approach" shown there exactly.
In the class Ui_MainWindow(object) I see,

        MainWindow.resize(400, 300)

so it should not be more than 400px across and 300 high plus the menu bar.
I also see

       self.menuBar.setGeometry(QtCore.QRect(0, 0, 400, 22))

which suggests the menu bar will be at 0,0, that is, upper left corner. Is
it?

All I can suggest is that you temporarily insert something like,
self.resize(200,100) after the call to setupUi() to force the window to be
smaller. Or you could use self.*setGeometry*(50,50,200,100) to ensure that
the upper left corner is on the screen.

And add a temporary print before the exit to show the current geometry,
    print(self.geometry().x(),
self.geometry().y(),self.geometry().width(),self.geometry().height() )

Then drag the window to a desirable starting size and position; quit; and
the print tells you how to set the geometry on startup. Later you can add
code to save the current geometry in your Settings on exit and load it on
startup.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150322/eaa53176/attachment.html>


More information about the PyQt mailing list