On Linux, window placement can be very unpredictable. See this section in the Qt documentation for a breakdown of the problems.
There is probably no general solution to the problem, but for me, setting up the geometry before the initial show() works:
... widget.setGeometry(200, 200, 100, 50) widget.show() app.exec_()
UPDATE
After some testing with the KDE window manager, I might have discovered a potential solution.
It seems that calling show() immediately after hide() does not give the window manager enough time to calculate the correct position of the window. Therefore, a simple way is to explicitly set the geometry after a short delay:
from PyQt4.QtGui import * from PyQt4.QtCore import QTimer app = QApplication([]) widget = QWidget() widget.setLayout(QVBoxLayout()) label = QLabel() widget.layout().addWidget(label) def hideShow(): widget.hide() QTimer.singleShot(25, showWidget) def showWidget(): widget.setGeometry(widget.geometry()) widget.show() widget.layout().addWidget(QPushButton('Hide/Show', clicked = hideShow)) widget.show() app.exec_()
This works for me using KDE-4.8 and OpenBox, but of course YMMV.
source share