当前位置:网站首页>PyQt5 - draw text on window
PyQt5 - draw text on window
2022-07-30 10:14:00 【Zhuangluo orange】
The effect is as follows:

The code is as follows:
'''Drawing API: Drawing Text1. Text2. Various graphics (line, point, ellipse, arc, sector, polygon, etc.)3. ImageQPainterpainter = QPainter()painter.begin()painter.drawText(...)painter.end()Various elements must be drawn in the paintEvent event method'''import sysfrom PyQt5.QtWidgets import QApplication,QWidgetfrom PyQt5.QtGui import QPainter,QColor,QFontfrom PyQt5.QtCore import Qtclass DrawText(QWidget):def __init__(self):super(DrawText, self).__init__()self.setWindowTitle('Draw text on the window')self.resize(300,200)self.text = "Python from rookie to expert"def paintEvent(self, event):painter = QPainter(self)painter.begin(self)painter.setPen(QColor(150,43,5))painter.setFont(QFont('SimSun',25))painter.drawText(event.rect(), Qt.AlignCenter, self.text)painter.end()if __name__ == '__main__':app = QApplication(sys.argv)main = DrawText()main.show()sys.exit(app.exec_())边栏推荐
- Quick Start Tutorial for flyway
- BERT pre-training model series summary
- Container Technology - A Simple Understanding of Kubernetes Objects
- The use of qsort function and its analog implementation
- 再有人问你分布式事务,把这篇扔给他
- Shell系统学习之函数
- Four ways the Metaverse is changing the way humans work
- flowable工作流所有业务概念
- CVTE校招笔试题+知识点总结
- EViews 12.0软件安装包下载及安装教程
猜你喜欢
随机推荐
Re20:读论文 What About the Precedent: An Information-Theoretic Analysis of Common Law
GNOME 新功能:安全启动被禁用时警告用户
快解析结合任我行crm
Redis Desktop Manager 2022.4.2 发布
Unified exception handling causes ResponseBodyAdvice to fail
Re19: Read the paper Paragraph-level Rationale Extraction through Regularization: A case study on European Court
Shell系统学习之数组
MySQL |子查询
编译报错: undefined reference to `google::FlagRegisterer::FlagRegisterer解决方法
Day113.尚医通:微信登录二维码、登录回调接口
通过构建一个顺序表——教你计算时间复杂度和空间复杂度(含递归)
线上靶机prompt.ml
JCL 学习
在机器人行业的专业人士眼里,机器人行业目前的情况如何?
最长公共序列、串问题总结
Flink_CDC搭建及简单使用
flyway的快速入门教程
Mysterious APT Attack
Security思想项目总结
(***重点***)Flink常见内存问题及调优指南(一)









