There is a small program with a set size, you need to make sure that when you start it, the window opens in the lower right corner of the screen, close to the edge on the right and to the taskbar from the bottom. I use PyQt5. Here is a snippet of code:

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

But the program opens in this way a little outside the screen and to the right and below, going far beyond the taskbar. The documentation says that frameGeometry () returns the size along with the frame of the window, although this is not my case, and because of this, everything is crooked. Please help. :)

  • not exactly the perfect solution, but after moving, make the shift to the left up to the desired number of pixels - Igor
  • such a solution does not fit, already had such an idea ... - Newbie

1 answer 1

To accurately place the window in the lower right corner, you must first display the window, then move it. To prevent flickering, you need to initially move the window beyond the screen:

 import sys from PyQt5.QtWidgets import QApplication, QWidget def move2RightBottomCorner(win): screen_geometry = QApplication.desktop().availableGeometry() screen_size = (screen_geometry.width(), screen_geometry.height()) win_size = (win.frameSize().width(), win.frameSize().height()) x = screen_size[0] - win_size[0] y = screen_size[1] - win_size[1] win.move(x, y) if __name__ == '__main__': app = QApplication(sys.argv) w = QWidget() w.move(w.width() * -3, 0) # чтобы не мелькало w.show() move2RightBottomCorner(w) sys.exit(app.exec_())