当前位置:网站首页>PyQt5 - Drawing different types of straight lines
PyQt5 - Drawing different types of straight lines
2022-07-30 10:14:00 【Zhuangluo orange】
The effect is as follows:
The code is as follows:
'''Draw different types of straight lines'''import sys,mathfrom PyQt5.QtWidgets import *from PyQt5.QtGui import *from PyQt5.QtCore import Qtclass DrawMultiLine(QWidget):def __init__(self):super(DrawMultiLine,self).__init__()self.resize(300,300)self.setWindowTitle('Set Pen's style')def paintEvent(self, event):painter = QPainter()painter.begin(self)pen = QPen(Qt.red,3,Qt.SolidLine)painter.setPen(pen)painter.drawLine(20,40,250,40)pen.setStyle(Qt.DashLine)painter.setPen(pen)painter.drawLine(20, 80, 250, 80)pen.setStyle(Qt.DashDotDotLine)painter.setPen(pen)painter.drawLine(20, 120, 250, 120)pen.setStyle(Qt.DotLine)painter.setPen(pen)painter.drawLine(20, 160, 250, 160)pen.setStyle(Qt.DashDotDotLine)painter.setPen(pen)painter.drawLine(20, 200, 250, 200)pen.setStyle(Qt.CustomDashLine)pen.setDashPattern([1,10,5,8])painter.setPen(pen)painter.drawLine(20, 240, 250, 240)size = self.size()painter.end()if __name__ == '__main__':app = QApplication(sys.argv)main = DrawMultiLine()main.show()sys.exit(app.exec_())
边栏推荐
- leetcode 剑指 Offer 63. 股票的最大利润
- ESP32 入门篇(一)使用 VS Code 进行开发环境安装
- kubernetes的一些命令
- 百度推广助手遇到重复关键字,验证错误,怎么一键删除多余的
- Soft test system architects introductory tutorial | system operation and software maintenance
- Always remember: one day you will emerge from the chrysalis
- By building a sequence table - teach you to calculate time complexity and space complexity (including recursion)
- Re17: Read the paper Challenges for Information Extraction from Dialogue in Criminal Law
- [100个Solidity使用技巧]1、合约重入攻击
- Determine whether a tree is a complete binary tree - video explanation!!!
猜你喜欢
Re19:读论文 Paragraph-level Rationale Extraction through Regularization: A case study on European Court
快解析结合任我行crm
柱状图 直方图 条形图 的区别
多线程--线程和线程池的用法
Quick Start Tutorial for flyway
Practical Walkthrough | Calculate Daily Average Date or Time Interval in MySQL
EViews 12.0软件安装包下载及安装教程
PyQt5-用像素点绘制正弦曲线
Re17:读论文 Challenges for Information Extraction from Dialogue in Criminal Law
leetcode 剑指 Offer 25. 合并两个排序的链表
随机推荐
STM32CubeMX配置生成FreeRTOS项目
kubernetes的一些命令
A new generation of free open source terminal tool, so cool
快解析结合用友时空
By building a sequence table - teach you to calculate time complexity and space complexity (including recursion)
leetcode 剑指 Offer 46. 把数字翻译成字符串
Re15: Read the paper LEVEN: A Large-Scale Chinese Legal Event Detection Dataset
In the robot industry professionals, Mr Robot industry current situation?
百度推广助手遇到重复关键字,验证错误,怎么一键删除多余的
flyway的快速入门教程
leetcode 剑指 Offer 52. 两个链表的第一个公共节点
北京突然宣布,元宇宙重大消息
Re19:读论文 Paragraph-level Rationale Extraction through Regularization: A case study on European Court
Shell系统学习之函数
(文字)无框按钮设置
连接mysql报错WARN: Establishing SSL connection without server‘s identity verification is not recommended
柱状图 直方图 条形图 的区别
BERT预训练模型系列总结
(Text) Frameless button settings
你真的懂Redis的5种基本数据结构吗?