02-屏幕坐标系-python+pycharm实现PyQt5

屏幕坐标系

学习笔记:PyQt5教程 来源b站
一起来交流

代码
import sys
from PyQt5.QtWidgets import QMainWindow, QApplication,QHBoxLayout,QWidget,QPushButton
from PyQt5.QtGui import QIcon
def onClick_Button():
    print("方法1--整个外围边框")
    print("widget.x=%d"%widget.x())
    print("widget.y=%d" % widget.y())
    print("widget.width=%d" % widget.width())
    print("widget.heught=%d" % widget.height())
    print("============================================")
    print("方法2-不含标题栏")
    print("widget.geometry().x()=%d" % widget.geometry().x())
    print("widget.geometry().y()=%d" % widget.geometry().y())
    print(" widget.geometry().width()=%d" % widget.geometry().width())
    print(" widget.geometry().height()=%d" % widget.geometry().height())
    print("=============================================")
    print("方法3---与方法一类似 高度增加了标题栏部分")
    print("widget.frameGeometry().x()=%d" % widget.frameGeometry().x())
    print("widget.frameGeometry().y()=%d" % widget.frameGeometry().y())
    print(" widget.frameGeometry().width()=%d" % widget.frameGeometry().width())
    print(" widget.frameGeometry().height()=%d" % widget.frameGeometry().height())
app=QApplication(sys.argv)

widget=QWidget()

# 设置按钮
button1=QPushButton(widget)
button1.setText("获取窗口坐标系")
button1.clicked.connect(onClick_Button)

# 对button1进行布局(即在窗口的具体坐标位置)
button1.move(24,25)

# 设置窗口大小
widget.resize(500,500)
# 对窗口进行布局(即窗口的具体坐标位置)
widget.move(300,300)
# 设置窗口名称
widget.setWindowTitle("屏幕坐标系")
widget.show()
sys.exit(app.exec_())
实现
方法1

在这里插入图片描述
在这里插入图片描述

方法2

在这里插入图片描述

在这里插入图片描述

方法3

在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

cqy阳

预祝上岸,感谢打赏

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值