New*_*bie 1 python user-interface pyqt python-3.x pyqt5
def location_on_the_screen(self):
fg = self.frameGeometry()
sbrp = QDesktopWidget().availableGeometry().bottomRight()
fg.moveBottomRight(sbrp)
self.move(fg.topLeft())
Run Code Online (Sandbox Code Playgroud)
我无法将窗口放置在屏幕的右下角。frameGeometry()无法正常工作。请帮助我,我该怎么办?
这是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_()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8052 次 |
| 最近记录: |