资源简介
本资源为QPainter绘制基础图形(二),利用鼠标拖动绘制。
代码片段和文件信息
import os
import time
import sys
FileName = os.path.basename(sys.argv[0])
FilePath = sys.argv[0].replace(FileName““)
UiName = FileName.replace(“.py““.ui“)
UiPath = FilePath +UiName
Ui_pyName = FilePath+“ui.py“
FileFlag = os.path.isfile(Ui_pyName)
if FileFlag == 0:
sys_cmd = os.popen(“pyuic5 “+UiPath+“ -o “+Ui_pyName)
time.sleep(1)
from ui import Ui_Form
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
class m_window(QWidgetUi_FormQPainter):
def __init__(self):
super(m_windowself).__init__()
self.setupUi(self)
self.pushButton.clicked.connect(self.DrawPoint)
self.pushButton_2.clicked.connect(self.DrawLine)
self.pushButton_3.clicked.connect(self.DrawElipse)
self.pushButton_4.clicked.connect(self.DrawRectangle)
self.pushButton_5.clicked.connect(self.DrawText)
self.pushButton_6.clicked.connect(self.DrawPolygon)
self.pushButton_7.clicked.connect(self.DrawPie)
self.pushButton_8.clicked.connect(self.DrawArc)
self.pushButton_9.clicked.connect(self.DrawPath)
self.Draw = ““
self.Line_list = [0000]
self.Point_list = []
self.Elipse_list = [0000]
self.Rectangle_list = [0000]
self.Polygon_list = []
self.Pie_list = [0000]
self.Arc_list = [0000]
def DrawLine(self):
self.update()
self.Draw = “Line“
def DrawPoint(self):
self.update()
self.Draw = “Point“
def DrawElipse(self):
self.update()
self.Draw = “Elipse“
def DrawRectangle(self):
self.update()
self.Draw = “Rectangle“
def DrawText(self):
self.update()
self.Draw = “Text“
def DrawPolygon(self):
self.update()
self.Draw = “Polygon“
def DrawArc(self):
self.update()
self.Draw = “Arc“
def DrawPie(self):
self.update()
self.Draw = “Pie“
def DrawPath(self):
self.update()
self.Draw = “Path“
def paintEvent(self QPaintEvent):
painter = QPainter(self)
painter.setPen(QColor(16666250))
painter.begin(self)
if self.Draw == “Line“:
painter.drawLine(self.Line_list[0]self.Line_list[1]self.Line_list[2]self.Line_list[3])
print(“DrawLine“)
elif self.Draw == “Point“:
len_point_list = len(self.Point_list)/2
for i in range(int(len_point_list)):
painter.drawPoint(self.Point_list[i*2]self.Point_list[i*2+1])
print(“DrawPoint“)
elif self.Draw == “Elipse“:
painter.drawEllipse(self.Elipse_list[0]self.Elipse_list[1]self.Elipse_list[2]self.Elipse_list[3])
print(“DrawElipse“)
elif self.Draw == “Rectangle“:
painter.drawRect(self.Rectangle_list[0]self.Rectangle_list[1]self.Rectangle_list[2]self.Rectangle_list[3])
print(“DrawRectangle“)
elif self.Draw == “Text“:
painter.drawText(120120“文字“)
print(“DrawText“)
elif self.Draw == “Polygon“:
polygon = QPolygon()
if len(self.Polygon_list) >= 6:
polygon.setPoints(self.Polygon_list)
print(len(self.Polygon_list))
painter.drawPo
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-07-07 09:42 Darw\
目录 0 2018-07-07 09:42 Darw\.vs\
目录 0 2018-07-07 09:42 Darw\.vs\Darw\
目录 0 2018-07-07 09:42 Darw\.vs\Darw\v15\
文件 23040 2018-07-07 19:24 Darw\.vs\Darw\v15\.suo
目录 0 2018-07-07 18:55 Darw\Darw\
文件 816 2018-07-07 09:42 Darw\Darw.sln
文件 5881 2018-07-07 18:55 Darw\Darw\Darw.py
文件 1515 2018-07-07 09:42 Darw\Darw\Darw.pyproj
文件 3009 2018-07-07 13:18 Darw\Darw\Darw.ui
文件 2857 2018-07-07 13:22 Darw\Darw\ui.py
目录 0 2018-07-07 13:22 Darw\Darw\__pycache__\
文件 1884 2018-07-07 13:22 Darw\Darw\__pycache__\ui.cpython-36.pyc
相关资源
- PyQt5:QtCharts 绘制折线图
- pyqt实现虚拟小键盘
- PyQt5高阶界面控件
- pyqt 软件打开和关闭淡入淡出的动画效
- bipyqf.rar
- PyQt5快速开发与实践
- PyQt5系列教程(二)利用QtDesigner设计
- qt QPainter 绘制跑马灯
- PyQt5:简单视频播放器
- Qt 使用QPainter类在子控件上画图
- 基于Qt绘制的时间轴demo
- 简单的数据库查询系统窗口实现
- PyQt入门指南
- QQLogin.ui
- PyQt5 tutorial PyQt5教程英文版
- Pyqt打开图片并显示
- 利用百度人脸识别API和pyqt5实现基于人
- chars-动态刷新.zip
- PyQt非常好的资料
- 笔趣阁小说器
- 网上爬的某学院PyQt教学视频
- pyqt5实现的登录功能
- QT5生成PDF
- QPainter 与QML SceneGraph绘制效率对比测试
- PyQt4入门指南 PDF中文版
- Qt中文语言包丨PyQt5汉化包附汉化说明
- PyQt examples
- designer_zh_CN.7z
- pyqt5与qt designer结合开发
- class48.ui
评论
共有 条评论