Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pyqt curves exemple

from PyQt5 import QtGui, QtCore
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys

class Window(QMainWindow):
    def __init__(self):
        super().__init__()
        self.title = "PyQt5 Drawing Tutorial"
        self.top= 150
        self.left= 150
        self.width = 500
        self.height = 500
        self.InitWindow()
    def InitWindow(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.top, self.left, self.width, self.height)
        self.show()
    def paintEvent(self, event):
        painter = QPainter(self)
        path = QPainterPath()
        points = [
            QPoint(20,40),
            QPoint(60,10),
            QPoint(100,50),
            QPoint(80,200),
            QPoint(200,300),
            QPoint(150,400),
            QPoint(350,450),
            QPoint(400,350),
            ]

        # draw small red dots on each point
        painter.setPen(QtCore.Qt.red)
        painter.setBrush(QBrush(Qt.red))
        for i in range(len(points)):
            painter.drawEllipse(points[i], 3, 3)

        painter.setPen(QtCore.Qt.blue)
        painter.setBrush(QBrush(Qt.red, Qt.NoBrush)) #reset the brush
        path.moveTo(points[0])

        # connect the points with blue straight lines
        #for i in range(len(points)-1):  # 1 less than length
        #    path.lineTo(points[i+1])

        # connect points with curve
        for i in range(0,len(points),2):
            path.quadTo(points[i], points[i+1])

        painter.drawPath(path)

App = QApplication(sys.argv)
window = Window()
sys.exit(App.exec())
Comment

PREVIOUS NEXT
Code Example
Python :: pool.map multiple arguments 
Python :: how to print using .sh file from python 
Python :: reload python repl 
Python :: howmanydays python 
Python :: Generators 
Python :: ipython run script with command line arguments 
Python :: pandas dtodays date csv 
Python :: python scroll 
Python :: scipy random seed 
Python :: Encapsulation in Python using public members 
Python :: solving differential equations in python 
Python :: django column to have duplicate of other 
Python :: Insert Multiple Images to Excel with Python 
Python :: free function in python 
Python :: int var def __init__(self,var=10): Initialize.var=var def display(): print var 
Python :: get number of occurrences of substring case independent python 
Python :: who is bayceee roblox id 
Python :: is Cross policy an issue with puppeteer / headless chrome? 
Python :: how to set time.sleep(2) on instapy 
Python :: checking number of connected users hotspot ubuntu 
Python :: get the hour of every instance of the date_time 
Python :: fibonacci using function in python 
Python :: BusyIndicator Import 
Python :: python using string to access objects 
Python :: python cat binary files together 
Python :: python last element of list using reverse() function 
Python :: effient way to find prime no inpython 
Python :: pygame is not defined 
Python :: install python3 yum centOS redhat 
Python :: Find number of triangles that can be made by given sides of triangle 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =