首页 > 其他 > 详细

pyqt5屏幕坐标系

时间:2020-10-22 09:44:42      阅读:91      评论:0      收藏:0      [点我收藏+]

我们直接用代码去理解屏幕坐标系

import sys
from PyQt5.QtWidgets import QHBoxLayout,QMainWindow,QApplication,QPushButton,QWidget
def onClick_Button():
    print("1")
    print("widget.x() = %d" % widget.x())    # 250 (窗口横坐标)
    print("widget.y() = %d" % widget.y())    # 200  (窗口纵坐标)
    print("widget.width() = %d" % widget.width())   # 300(工作区宽度)
    print("widget.height() = %d" % widget.height()) # 240 (工作区高度)

    print("2")
    print("widget.geometry().x() = %d" % widget.geometry().x()) # 250 (工作区横坐标)
    print("widget.geometry().y() = %d" % widget.geometry().y()) # 222  (工作区纵坐标)
    print("widget.geometry().width() = %d" % widget.geometry().width() )  # 300(工作区宽度)
    print("widget.geometry().height() = %d" % widget.geometry().height()) # 240 (工作区高度)

    print("3")
    print("widget.frameGeometry().x() = %d" % widget.frameGeometry().x())  # 250 (窗口横坐标)
    print("widget.frameGeometry().y() = %d" % widget.frameGeometry().y())  # 200  (窗口纵坐标)
    print("widget.frameGeometry().width() = %d" % widget.frameGeometry().width() )  # 300(窗口宽度)
    print("widget.frameGeometry().height() = %d" % widget.frameGeometry().height()) # 262(窗口高度)

app = QApplication(sys.argv)

widget = QWidget()
btn = QPushButton(widget)
btn.setText("按钮")
btn.clicked.connect(onClick_Button)

btn.move(24,52)

widget.resize(300,240)   # 设置工作区的尺寸

widget.move(250,200)

widget.setWindowTitle(屏幕坐标系)

widget.show()

sys.exit(app.exec_())

 

pyqt5屏幕坐标系

原文:https://www.cnblogs.com/ranzhong/p/13855629.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!