当前位置:网站首页>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_())边栏推荐
- Meikle Studio - see the actual combat notes of Hongmeng equipment development five - drive subsystem development
- leetcode 剑指 Offer 58 - I. 翻转单词顺序
- CVTE校招笔试题+知识点总结
- Domino Server SSL Certificate Installation Guide
- 判断一颗树是否为完全二叉树——视频讲解!!!
- C#中Config文件中,密码的 特殊符号的书写方法。
- JVM内存布局、类加载机制及垃圾回收机制详解
- leetcode 剑指 Offer 63. 股票的最大利润
- Version management of public Jar packages
- ThreadLocal内存泄漏是伪命题?
猜你喜欢
容器技术 -- 简单了解 Kubernetes 的对象

idea2021+Activiti【最完整笔记一(基础使用)】

学习笔记11--局部轨迹直接构造法

论文阅读:SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers

Re19: Read the paper Paragraph-level Rationale Extraction through Regularization: A case study on European Court

国外资源加速下载器,代码全部开源

spark udf 接受并处理 null值.

(Text) Frameless button settings

Practical Walkthrough | Calculate Daily Average Date or Time Interval in MySQL

(C language) file operation
随机推荐
(***重点***)Flink常见内存问题及调优指南(一)
what is this method called
idea2021+Activiti [the most complete note one (basic use)]
SST-Calib:结合语义和VO进行时空同步校准的lidar-visual外参标定方法(ITSC 2022)
自适应控制——仿真实验一 用李雅普诺夫稳定性理论设计自适应规律
Practical Walkthrough | Calculate Daily Average Date or Time Interval in MySQL
CVTE school recruitment written test questions + summary of knowledge points
606. Create a string from a binary tree (video explanation!!!)
Determine whether a tree is a complete binary tree - video explanation!!!
Materialist Dialectics - Conditionalism
105. 从前序与中序遍历序列构造二叉树(视频讲解!!)
线上靶机prompt.ml
Multi-threading scheme to ensure that a single thread opens a transaction and takes effect
105. Construct binary tree from preorder and inorder traversal sequence (video explanation!!)
实战演练 | 在 MySQL 中计算每日平均日期或时间间隔
Re20:读论文的先例:普通法的信息理论分析
柱状图 直方图 条形图 的区别
线程池方式开启线程--submit()和execute()的区别
这种叫什么手法
JCL 学习