[PyQt] centralization of QWidget
Cihangir Aktürk
cakturk at gmail.com
Fri Aug 31 10:42:23 BST 2012
On Thu, Aug 30, 2012 at 11:37 PM, Python.py <dsishimori at gmail.com> wrote:
> I'm trying to get my application when run, appear in the middle of the
> screen. Whenever it starts at the top right. Someone can tell me how can I
> do to always leave sentralizado? I'm using QWidget, tried to use in function
Hi,
I am not aware of Center() function, but using the following snippet
any widget can be easily centered.
from PyQt4 import Qt as qt
def center_widget(w):
d = qt.QApplication.desktop()
screen_w = d.width()
screen_h = d.height()
widget_w = w.width()
widget_h = w.height()
x = (screen_w - widget_w) / 2
y = (screen_h - widget_h) /2
w.move(x, y)
if __name__ == '__main__':
app = qt.QApplication([])
win = qt.QWidget()
win.show()
center_widget(win)
app.exec_()
regards.
Cihangir Akturk
More information about the PyQt
mailing list