zoukankan      html  css  js  c++  java
  • pyqt5屏幕坐标系

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

    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_())
  • 相关阅读:
    编程风格与注意事项(一)
    BB-Black 初体验之远程控制篇
    我的BB-Black之旅……(一)
    等精度频率计设计中的猫腻
    Linux查看物理CPU个数、核数、逻辑CPU个数、Cpu型号
    基于TransportClient的elasticsearch(es)消费kafka数据---Java程序设计
    elasticsearch概述
    HBase 性能优化笔记
    hive1.2.1搭建遇到的问题
    Hbase的表设计
  • 原文地址:https://www.cnblogs.com/ranzhong/p/13855629.html
Copyright © 2011-2022 走看看