Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyQt - Location of the window

def location_on_the_screen(self):
    fg = self.frameGeometry()
    sbrp = QDesktopWidget().availableGeometry().bottomRight()
    fg.moveBottomRight(sbrp)
    self.move(fg.topLeft())

I can't place the window in the bottom right corner of the screen. frameGeometry() not working as it should. Help me, please, what can I do?

like image 661
Newbie Avatar asked Feb 07 '23 08:02

Newbie


1 Answers

Here's a possible solution for windows:

import sys

from PyQt5.QtWidgets import QApplication, QWidget, QDesktopWidget


class MyWidget(QWidget):

    def __init__(self):
        super().__init__()
        self.setFixedSize(400, 300)

    def location_on_the_screen(self):
        ag = QDesktopWidget().availableGeometry()
        sg = QDesktopWidget().screenGeometry()

        widget = self.geometry()
        x = ag.width() - widget.width()
        y = 2 * ag.height() - sg.height() - widget.height()
        self.move(x, y)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    widget = MyWidget()
    widget.location_on_the_screen()
    widget.show()
    app.exec_()
like image 126
BPL Avatar answered Feb 13 '23 07:02

BPL