Пример #1
0
	def __init__(self, parent = None, message = None, itemType = "log"):
		QListWidgetItem.__init__(self)
		self.itemType = itemType

		if (itemType == "log"):
			self.setText("--- " + str(message))
		elif (itemType == "in"):
			self.setText("<<< " + str(message))
		elif (itemType == "out"):
			self.setText(">>> " + str(message))
		else:
			self.setText(str(message))

		font = QFont()
		font.setFamily("Monospace")
		if (itemType == "in") or (itemType == "out"):
			font.setBold(True)
			font.setWeight(75)
		else:
			font.setBold(False)
			font.setWeight(50)
		self.setFont(font)

		brush = QBrush(QColor(0, 0, 0))
		if (itemType == "in"):
			brush = QBrush(QColor(0, 0, 85))
		elif (itemType == "out"):
			brush = QBrush(QColor(0, 85, 0))
		brush.setStyle(Qt.NoBrush)
		self.setForeground(brush)
 def setStyle(self, painter, fillColor, penColor, stroke):
     brush = QBrush()
     pen = QPen(penColor, stroke)
     brush.setColor(fillColor)
     brush.setStyle(Qt.SolidPattern)
     painter.setBrush(brush)
     painter.setPen(pen)
     painter.setRenderHint(QPainter.Antialiasing)
Пример #3
0
 def paintEvent(self, ev):
     pen = QPen()
     pen.setStyle(Qt.DotLine)
     pen.setWidth(2)
     pen.setColor(QColor(Qt.white))
     brush = QBrush()
     brush.setStyle(Qt.SolidPattern)
     brush.setColor(QColor(0, 0, 0))
     painter = QPainter(self)
     painter.setPen(pen)
     painter.setBrush(brush)
     painter.drawRect(ev.rect())
Пример #4
0
 def drawShape(self, event, qp):
     pen = QPen(Qt.yellow)
     pen.setWidth(3)
     # rellenar fondo con patron de imagen
     brush = QBrush()
     brush.setTexture(QPixmap('image/small_image.jpg'))
     # establecer el QBrush
     qp.setBrush(brush)
     qp.setPen(pen)
     qp.drawRoundedRect(QRect(50, 50, 200, 150), 15, 15)
     # utilizar un patron predefinido
     brush.setStyle(Qt.DiagCrossPattern)
     qp.setBrush(brush)
     qp.drawEllipse(350, 50, 150, 150)
Пример #5
0
    def paintEvent(self, event):
        super().paintEvent(event)
        
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        
        size = self.size()
        brush = QBrush()

        rect = QtCore.QRect(0, 0, size.width(), size.height())
        #painter.fillRect(rect, brush)

        switchWidth = size.width()/2 - 2            
        switchHeight = size.height()/2 - 2
        ## rect.moveCenter(QPoint(size.width()/2,size.height()/2))
        center_x = size.width()/2
        center_y = size.height()/2
        centerpoint = QPoint(center_x,center_y)
        
        if (self.curState):
            brush.setColor(self.onColor)
            painter.setPen(QPen(self.onColor,0))
        else:
            brush.setColor(self.offColor)
            painter.setPen(QPen(self.offColor,0))
            
        brush.setStyle(Qtc.SolidPattern)
        painter.setBrush(brush)
        
        # Draw the switch background
        centerRect = QRect(size.width()/4,0,size.width()/2-4,size.height())
        painter.drawRect(centerRect)
        painter.drawEllipse(0,0,size.height(),size.height())
        painter.drawEllipse(size.width()/2,0,size.height(),size.height())

        # Draw the switch itself
        brush.setColor(QColor('white'))
        painter.setBrush(brush)
        painter.setPen(QPen(QColor('white'),0))
        actualSwitchWidth = min(switchWidth/2,switchHeight)
        if self.curState:
            painter.drawEllipse(2,2,size.height() - 4,size.height() - 4)
        else:
            painter.drawEllipse(center_x+2,2,size.height() - 4,size.height() - 4)
Пример #6
0
    def drawRect(self, qp):
        # 创建红色,宽度为4像素的画笔
        pen = QPen()
        pen.setWidth(4)
        pen.setColor(Qt.red)
        pen.setStyle(Qt.SolidLine)
        pen.setCapStyle(Qt.FlatCap)
        pen.setJoinStyle(Qt.BevelJoin)
        qp.setPen(pen)

        qp.setRenderHint(QPainter.Antialiasing)
        qp.setRenderHint(QPainter.TextAntialiasing)
        brush = QBrush()
        qc = QColor()
        qc.lighter()
        brush.setColor(qc.lighter(1))
        brush.setStyle(Qt.SolidPattern)
        qp.setBrush(brush)
        qp.drawRect(*self.rect)
Пример #7
0
 def paintEvent(self,e):
     if self.alive == False:
         SCREENW = QDesktopWidget().screenGeometry(-1).width()
         SCREENH = QDesktopWidget().screenGeometry(-1).height()
         painter = QPainter(self)
         brush = QBrush()
         brush.setColor(QColor('black'))
         brush.setStyle(Qt.SolidPattern)
         rect = QtCore.QRect(0,0,SCREENH,SCREENH)
         painter.fillRect(rect,brush)
     else:
         SCREENW = QDesktopWidget().screenGeometry(-1).width()
         SCREENH = QDesktopWidget().screenGeometry(-1).height()
         painter = QPainter(self)
         brush = QBrush()
         brush.setColor(QColor('white'))
         brush.setStyle(Qt.SolidPattern)
         rect = QtCore.QRect(0, 0, SCREENH, SCREENH)
         painter.fillRect(rect, brush)
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setupUi(self)
        self.pushButton.clicked.connect(self.run)
        self.setGeometry(300, 300, 400, 400)
        self.setWindowTitle('Окружность')

        palette = QPalette()
        brush = QBrush(QColor(100, 100, 100))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Window, brush)
        self.setPalette(palette)

        self.r = randint(10, 100)
        self.color1 = randint(0, 255)
        self.color2 = randint(0, 255)
        self.color3 = randint(0, 255)

        self.show()
Пример #9
0
    def drawChangeIndicatorGauge(self, xRef, yRef, radius, expectedMaxChange, value, color, painter, solid):
        # Draw the circle
        circlePen = QPen(Qt.SolidLine)
        if solid == False:
            circlePen.setStyle(Qt.DotLine)
        circlePen.setColor(self.defaultColor)
        circlePen.setWidth(self.refLineWidthToPen(2.0))
        painter.setBrush(Qt.NoBrush)
        painter.setPen(circlePen)
        self.drawCircle(xRef, yRef, radius, 200.0, 170.0, 1.5, color, painter)

        label = '{:05.1f}'.format(value)

        _textSize = radius / 2.5

        # Draw the value
        self.paintText(label, color, _textSize, xRef-_textSize*1.7, yRef-_textSize*0.4, painter)

        # Draw the needle
        # Scale the rotation so that the gauge does one revolution
        # per max. change
        _rangeScale = (2.0 * M_PI) / expectedMaxChange
        _maxWidth = radius / 10.0
        _minWidth = _maxWidth * 0.3

        p = QPolygonF(6)
        p.replace(0, QPointF(xRef-_maxWidth/2.0, yRef-radius * 0.5))
        p.replace(1, QPointF(xRef-_minWidth/2.0, yRef-radius * 0.9))
        p.replace(2, QPointF(xRef+_minWidth/2.0, yRef-radius * 0.9))
        p.replace(3, QPointF(xRef+_maxWidth/2.0, yRef-radius * 0.5))
        p.replace(4, QPointF(xRef,              yRef-radius * 0.46))
        p.replace(5, QPointF(xRef-_maxWidth/2.0, yRef-radius * 0.5))

        self.rotatePolygonClockWiseRad(p, value*_rangeScale, QPointF(xRef, yRef))

        indexBrush = QBrush()
        indexBrush.setColor(self.defaultColor)
        indexBrush.setStyle(Qt.SolidPattern)
        painter.setPen(Qt.SolidLine)
        painter.setPen(self.defaultColor)
        painter.setBrush(indexBrush)
        self.drawPolygon(p, painter)
Пример #10
0
class BaseTkPy3(QWidget):
    open_file_event = pyqtSignal(str)

    def __init__(self, parent=None):
        super(BaseTkPy3, self).__init__(parent)
        self.layout = QHBoxLayout()
        self.splitter = QSplitter()
        self.mdi = TkPyMdiArea()
        self.mdi_background_style = QBrush(QColor(160, 160, 160, 255))
        self.mdi_background_style.setStyle(Qt.Dense4Pattern)
        self.mdi.setBackground(self.mdi_background_style)
        self.mdi.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.mdi.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.mdi.setObjectName('WindowMdi')
        self.init_ui()

    def init_ui(self):
        self.setLayout(self.layout)
        self.splitter.addWidget(self.mdi)
        self.layout.addWidget(self.splitter, 0)
Пример #11
0
	def drawBox(self,qp,x,y,width,height,index,points):
		
		brush = QBrush()
		brush.setStyle(Qt.SolidPattern)
		brush.setColor(QColor(150, 150, 150))
		qp.setBrush(brush)

		pen = QPen(Qt.black, 2, Qt.SolidLine)
		qp.setPen(pen)

		rect1=QRect(x*self.minimumTileSize, y*self.minimumTileSize, width*self.minimumTileSize, height*self.minimumTileSize)

		if points>0:
			brush.setStyle(Qt.Dense2Pattern)
			qp.setBrush(brush)
			qp.drawRect(rect1)             
			qp.drawText(rect1, Qt.AlignCenter,"[{0}]\n{1}".format(index,points))    
		else:
			qp.drawRect(rect1) 
			qp.drawText(rect1, Qt.AlignCenter,"[{0}]".format(index)) 
Пример #12
0
    def draw(self, p: QPainter, scale: float):
        p.save()
        if self.selected:
            pen = QPen(QColor("red"))
            pen.setWidthF(2)
        else:
            pen = QPen(QColor("black"))
            pen.setWidthF(1)

        pen.setCosmetic(True)
        p.setPen(pen)
        brush = QBrush(QColor("Black"))
        transform = QTransform()
        transform.scale(1 / scale, 1 / scale)
        brush.setTransform(transform)
        brush.setStyle(Qt.BDiagPattern)

        p.setBrush(brush)
        p.drawRect(QRectF(self.x, self.y, self.w, self.h))
        p.restore()
Пример #13
0
    def paintEvent(self, event):
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.setRenderHint(QPainter.TextAntialiasing)

        pen = QPen()
        pen.setWidth(2)
        pen.setColor(Qt.red)
        painter.setPen(pen)

        texturePixmap = QPixmap("../image/texture2.jpg")
        brush = QBrush()
        brush.setStyle(Qt.TexturePattern)
        brush.setTexture(texturePixmap)
        painter.setBrush(brush)

        W = self.width()
        H = self.height()
        rect = QRect(W / 5, H / 5, 3 * W / 5, 3 * H / 5)
        painter.drawRect(rect)
Пример #14
0
 def setLine(color, row, column, text, icon=None):
     try:
         brush = QBrush(color)
         brush.setStyle(Qt.SolidPattern)
         i = Globals.MainWindow.R_RaceLive.item(row, column)
         if i == None:
             i = QTableWidgetItem(text)
             Globals.MainWindow.R_RaceLive.setItem(row, column, i)
         else:
             i.setText(text)
         i.setBackground(brush)
         if icon is not None:
             i.setIcon(icon)
         else:
             i.setIcon(QIcon())
     except Exception as e:
         print("in update, setLine( color,%d,%d,%s)" %
               (row, column, text))
         print(color)
         print(e)
Пример #15
0
    def on_click(self, event):

        if not self.image_stack or not event.inaxes:
            return

        clicked_x = float(event.xdata)
        clicked_y = float(event.ydata)

        centre = (clicked_x, clicked_y)

        if self.stimulate_points_collection.insertRow(self.stimulate_points_collection.rowCount()):
            row = self.stimulate_points_collection.rowCount() - 1

            model_index = self.stimulate_points_collection.index(row, 0)
            self.stimulate_points_collection.setData(model_index=model_index, value=row)

            model_index = self.stimulate_points_collection.index(row, 1)
            self.stimulate_points_collection.setData(model_index=model_index, value=self.current_frame)

            model_index = self.stimulate_points_collection.index(row, 2)
            self.stimulate_points_collection.setData(model_index=model_index, value=centre)

            model_index = self.stimulate_points_collection.index(row, 4)
            self.stimulate_points_collection.setData(model_index=model_index,
                                                     value=self.stimulate_point_width_input.value())

            new_stimulus_point = self.stimulate_points_collection.data[-1]
            width = self.stimulate_point_width_input.value()
            rect = QRectF(-width / 2, -width / 2, width, width)
            brush = QBrush()
            brush.setStyle(Qt.SolidPattern)
            brush.setColor(Qt.white)
            new_stimulus_point.setBrush(brush)
            new_stimulus_point.setRect(rect)
            # self.scene.addItem(new_stimulus_point)
            # new_stimulus_point.setVisible(False)
            new_stimulus_point.setPos(clicked_x, clicked_y)

            self.draw_stimulate_point(new_stimulus_point)
            self.draw_stimulate_point_index(new_stimulus_point)
            self.canvas.draw()
Пример #16
0
    def __init__(self, parent=None):
        super().__init__(parent)
        width = 50
        half_width = width / 2
        self.rect = QRectF(-half_width, -half_width, width, width)
        brush = QBrush()
        brush.setStyle(Qt.SolidPattern)
        brush.setColor(Qt.red)
        self.camera_square = DraggableStimulusSquare(
            self.on_camera_square_selected_has_changed)
        self.camera_square.setBrush(brush)
        self.camera_square.setRect(self.rect)

        brush = QBrush()
        brush.setStyle(Qt.SolidPattern)
        brush.setColor(Qt.white)

        self.stimulus_window_square = GLDraggableStimulusSquare(
            self.on_stimulus_window_square_selected_has_changed)
        self.stimulus_window_square.setBrush(brush)
        self.stimulus_window_square.setRect(self.rect)
Пример #17
0
    def __init__(self,
                 location=(0, 0),
                 frame=-1,
                 index=-1,
                 intensity=1.0,
                 size=1.0,
                 parent=None):
        super().__init__(parent)
        self._intensity = intensity
        self.frame = frame
        self._location = location
        self.index = index
        self._size = size

        rect = QRectF(-size / 2, -size / 2, size, size)
        brush = QBrush()
        brush.setStyle(Qt.SolidPattern)
        brush.setColor(Qt.white)
        self.setBrush(brush)
        self.setRect(rect)
        self.setPos(location[0], location[1])
Пример #18
0
 def __init__(self):
     super(QFramesInTracksScene, self).__init__()
     self._coords = CoordTransform()
     self._track_items = {}
     self._frame_items = {}
     pen = QPen()
     pen.setWidthF(1.25)
     pen.setColor(Qt.black)
     # pen.setCapStyle(Qt.RoundCap)
     pen.setJoinStyle(Qt.RoundJoin)
     brush = QBrush()
     brush.setColor(Qt.blue)
     brush.setStyle(Qt.SolidPattern)
     self._frame_pen_brush = pen, brush
     pen = QPen(pen)
     pen.setWidthF(3.5)
     pen.setJoinStyle(Qt.RoundJoin)
     pen.setColor(Qt.blue)
     brush = QBrush(brush)
     brush.setColor(Qt.gray)
     self._track_pen_brush = pen, brush
Пример #19
0
    def paintEvent(self, event):
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.setRenderHint(QPainter.TextAntialiasing)

        pen = QPen()
        pen.setWidth(3)
        pen.setColor(Qt.red)
        pen.setStyle(Qt.SolidLine)
        pen.setCapStyle(Qt.FlatCap)
        pen.setJoinStyle(Qt.BevelJoin)
        painter.setPen(pen)

        brush = QBrush()
        brush.setColor(Qt.yellow)
        brush.setStyle(Qt.SolidPattern)
        painter.setBrush(brush)

        W = self.width()
        H = self.height()
        rect = QRect(W/4, H/4, W/2, H/2)
        painter.drawRect(rect)
Пример #20
0
    def paintEvent(self, event):
        super().paintEvent(event)

        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)

        size = self.size()
        brush = QBrush()

        center_x = size.width() / 2

        if self.curState:
            brush.setColor(self.onColor)
            painter.setPen(QPen(self.onColor, 0))
        else:
            brush.setColor(self.offColor)
            painter.setPen(QPen(self.offColor, 0))

        brush.setStyle(Qtc.SolidPattern)
        painter.setBrush(brush)

        # Draw the switch background
        centerRect = QRect(size.width() / 4, 0,
                           size.width() / 2 - 4, size.height())
        painter.drawRect(centerRect)
        painter.drawEllipse(0, 0, size.height(), size.height())
        painter.drawEllipse(size.width() / 2, 0, size.height(), size.height())

        # Draw the switch itself
        brush.setColor(QColor('white'))
        painter.setBrush(brush)
        painter.setPen(QPen(QColor('white'), 0))
        if self.curState:
            painter.drawEllipse(center_x + 2, 2,
                                size.height() - 4,
                                size.height() - 4)
        else:
            painter.drawEllipse(2, 2, size.height() - 4, size.height() - 4)
    def paintEvent(self, event):
        color = self.color if not self.hiding else QColor(0,0,0,0)

        pen = QPen()
        pen.setWidth(self.width()/8)
        pen.setCapStyle(Qt.RoundCap)
        pen.setColor(color)

        brush = QBrush()
        brush.setStyle(Qt.SolidPattern)
        brush.setColor(color)

        painter = QPainter(self)
        painter.setPen(pen)
        painter.setBrush(brush)

        points = [ QPointF(*v.lerp(eval(self.kernel), self.width())) for v in self.verts ]
        painter.drawLine(QLineF(points[0],points[1]))
        painter.drawLine(QLineF(points[1],points[2]))
        painter.drawLine(QLineF(points[2],points[0]))

        poly = QPolygonF(points)
        painter.drawPolygon(poly)
Пример #22
0
 def showTable(self, tb_data):
     tbdata = json.loads(tb_data)
     print(tbdata)
     # cols = len(tbdata['header'])
     cols = len(tbdata['tbody'][0])    
     rows = len(tbdata['tbody'])
     self.tableWidget.setColumnCount(cols)
     self.tableWidget.setRowCount(rows)
     self.tableWidget.setHorizontalHeaderLabels(tbdata['header'])
     for i in range(self.tableWidget.rowCount()):
         for j in range(self.tableWidget.columnCount()):
             cnt = tbdata['tbody'][i][j]
             if i % 3 == 2:
                 if type(cnt) == float:
                     newItem = QTableWidgetItem(str(round(cnt, 2)))
                 else:
                     newItem = QTableWidgetItem(str(cnt))
             else:
                 if type(cnt) == float:
                     newItem = QTableWidgetItem(cov_float_to_hhmm(cnt))
                 else:
                     newItem = QTableWidgetItem(str(cnt))
             if j == self.tableWidget.columnCount() - 1 and i % 3 == 2:
                 brush = QBrush(QColor(200, 139, 33))
                 brush.setStyle(Qt.SolidPattern)
                 newItem.setBackground(brush)
                 brush = QBrush(QColor(24, 37, 216))
                 brush.setStyle(Qt.SolidPattern)
                 newItem.setForeground(brush)
             self.tableWidget.setItem(i, j, newItem)
     self.tableWidget.setColumnWidth(0, 50)
     self.tableWidget.setColumnWidth(1, 40)
     self.tableWidget.setColumnWidth(self.tableWidget.columnCount() - 1, 50)
     for i in range(cols - 3):
         self.tableWidget.setColumnWidth(i + 2, 40)
     for spr in range(int(rows / 3)):
         self.tableWidget.setSpan(3 * spr, 0, 3, 1)
Пример #23
0
    def __draw02_textureBrush(self):  #在窗口上绘图
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.setRenderHint(QPainter.TextAntialiasing)

        #设置画笔
        pen = QPen()
        pen.setWidth(3)  #线宽
        pen.setColor(Qt.red)  #划线颜色

        ## Qt::NoPen,Qt::SolidLine, Qt::DashLine, Qt::DotLine,Qt::DashDotLine,Qt::DashDotDotLine,Qt::CustomDashLine
        pen.setStyle(Qt.SolidLine)  #线的类型,实线、虚线等

        ## Qt::FlatCap, Qt::SquareCap,Qt::RoundCap
        pen.setCapStyle(Qt.RoundCap)  #线端点样式

        ## Qt::MiterJoin,Qt::BevelJoin,Qt::RoundJoin,Qt::SvgMiterJoin
        pen.setJoinStyle(Qt.RoundJoin)  #线的连接点样式

        painter.setPen(pen)

        ##设置画刷
        texturePixmap = QPixmap("texture.jpg")
        brush = QBrush()
        ##      brush.setColor(Qt.yellow)     #画刷颜色
        ##      brush.setStyle(Qt.SolidPattern)  #填充样式
        brush.setStyle(Qt.TexturePattern)  #画刷填充样式
        brush.setTexture(texturePixmap)  #设置材质图片
        painter.setBrush(brush)

        ##绘图
        W = self.width()  #绘图区宽度
        H = self.height()  #绘图区高度

        rect = QRect(W / 4, H / 4, W / 2, H / 2)
        painter.drawRect(rect)
Пример #24
0
    def listprint(self, head, msg):
        print(self.sctl.handleError())
        brush = QBrush(QColor(255, 213, 214))
        brush.setStyle(Qt.SolidPattern)
        item1 = QListWidgetItem()
        item1.setBackground(brush)
        item1.setText(
            QCoreApplication.translate("Ui_MainWindow", '{}:'.format(head)))

        brush = QBrush(QColor(205, 232, 255))
        brush.setStyle(Qt.SolidPattern)
        item2 = QListWidgetItem()
        item2.setBackground(brush)
        item2.setText(
            QCoreApplication.translate("Ui_MainWindow",
                                       '        {}'.format(msg)))
        self.listWidget_danmaku.addItem(item1)
        self.listWidget_danmaku.addItem(item2)
        self.listWidget_danmaku.addItem('')
        item2.setHidden(False)
        item1.setHidden(False)
        for i in range(2):
            self.listWidget_danmaku.scrollToBottom()
            time.sleep(0.1)
Пример #25
0
 def brush(self, ):
     # this function returns a QBrush based on the format settings
     aBrush = QBrush()
     aColor = QColor()
     QColor.setNamedColor(aColor, self.formatDict["fillColor"])
     aBrush.setColor(aColor)
     if self.formatDict["fillStyle"] == "None":
         aBrush.setStyle(Qt.NoBrush)
     if self.formatDict["fillStyle"] == "Fill":
         aBrush.setStyle(Qt.SolidPattern)
     if self.formatDict["fillStyle"] == "Pattern":
         aBrush.setStyle(int(self.formatDict["patternNumber"])+1) 
     return aBrush
Пример #26
0
    def setTiles(self):

        #background
        brush = QBrush(
        )  #QBrush(画刷)是一个基本的图形对象,用于填充如矩形,椭圆形,多边形等形状,QBrush有三种类型,预定义,过渡,和纹理图案
        pix = QPixmap(os.getcwd() + "/robotImages/tile.png")
        brush.setTexture(pix)
        brush.setStyle(24)
        self.setBackgroundBrush(brush)

        #wall:left、right、top、bottom都是QGraphicsRectItem类型
        #left
        left = QGraphicsRectItem()
        pix = QPixmap(os.getcwd() + "/robotImages/tileVert.png")  #获取贴图
        left.setRect(QRectF(0, 0, pix.width(),
                            self.height))  #尺寸:宽是图片宽度 ,高度是战场高度
        brush.setTexture(pix)  #设置贴图函数
        brush.setStyle(
            24
        )  #参数24指平铺格式(参数为枚举类型)详情见 https://doc.qt.io/qt-5/qt.html#BrushStyle-enum
        left.setBrush(brush)
        left.name = 'left'
        self.addItem(left)

        #right
        right = QGraphicsRectItem()
        right.setRect(self.width - pix.width(), 0, pix.width(),
                      self.height)  #尺寸:宽是图片的宽度、高是战场的高
        right.setBrush(brush)
        right.name = 'right'
        self.addItem(right)

        #top
        top = QGraphicsRectItem()
        pix = QPixmap(os.getcwd() + "/robotImages/tileHori.png")
        top.setRect(QRectF(0, 0, self.width, pix.height()))
        brush.setTexture(pix)
        brush.setStyle(24)
        top.setBrush(brush)
        top.name = 'top'
        self.addItem(top)

        #bottom
        bottom = QGraphicsRectItem()
        bottom.setRect(0, self.height - pix.height(), self.width, pix.height())
        bottom.setBrush(brush)
        bottom.name = 'bottom'
        self.addItem(bottom)
Пример #27
0
    def QuartusUpdateWindow(self, updateText, color):
        currItem = QListWidgetItem(self.drop_box)

        NM_Stat = self.secretButton.NIGHT_MODE
        grnColor = QBrush()  # Green
        grnColor.setStyle(Qt.SolidPattern)

        redColor = QBrush()  # Red
        redColor.setStyle(Qt.SolidPattern)

        blueColor = QBrush()  # blue
        blueColor.setStyle(Qt.SolidPattern)

        if NM_Stat == True:
            grnColor.setColor(QColor('#98FB98'))
            redColor.setColor(QColor('red'))
            blueColor.setColor(QColor('cyan'))

        else:
            grnColor.setColor(QColor('#00A86B'))
            redColor.setColor(QColor('red'))
            blueColor.setColor(QColor('blue'))

        if color == "GREEN":
            currItem.setForeground(grnColor)
            currItem.setText(updateText)
            self.drop_box.addItem(currItem)

        elif color == "BLUE":
            currItem.setForeground(blueColor)
            currItem.setText(updateText)
            self.drop_box.addItem(currItem)

        elif color == "RED":
            currItem.setForeground(redColor)
            currItem.setText(updateText)
            self.drop_box.addItem(currItem)

        self.drop_box.scrollToBottom()
Пример #28
0
    def drawRoundedRects(self, painter):
        """
        Examples of how to draw rectangles with
        rouneded corners with QPainter.
        """
        pen = QPen(QColor(self.black))
        brush = QBrush(QColor(self.black))

        rect_1 = QRect(420, 340, 40, 60)
        rect_2 = QRect(480, 300, 50, 40)
        rect_3 = QRect(540, 240, 40, 60)

        painter.setPen(pen)
        brush.setStyle(Qt.Dense1Pattern)
        painter.setBrush(brush)
        painter.drawRoundedRect(rect_1, 8, 8)

        brush.setStyle(Qt.Dense5Pattern)
        painter.setBrush(brush)
        painter.drawRoundedRect(rect_2, 5, 20)

        brush.setStyle(Qt.BDiagPattern)
        painter.setBrush(brush)
        painter.drawRoundedRect(rect_3, 15, 15)
Пример #29
0
class SnakeGame(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent=parent)
        self.setStyleSheet("border: 1px solid black;")
        # self.resize(1000, 1000)
        self.display_width = self.width()
        self.display_height = self.height()
        # self.setGeometry(0, 0, 1000, 1000)

        self.resize(1000, 1000)
        # self.display_width = 1000
        # self.display_height = 1000

        self.label = QLabel(self)
        self.initialize()

    def initialize(self):
        self.canvas = QImage(self.display_width, self.display_height,
                             QImage.Format_RGBA8888)
        self.background = QImage(self.display_width, self.display_height,
                                 QImage.Format_RGBA8888)
        self.snake_ebene = QImage(self.display_width, self.display_height,
                                  QImage.Format_RGBA8888)

        self.timer = QTimer()
        self.timer.setInterval(300)
        self.timer.timeout.connect(self.update)
        self.timer.start(0)

        self.snake = Snake(0, 0)

        ## Painter & Brush
        self.painter_canvas = QPainter(self.canvas)
        self.painter_background = QPainter(self.background)
        self.painter_snake = QPainter(self.snake_ebene)

        self.brush = QBrush()

    def keyPressEvent(self, e):
        if e.key() == Qt.Key_Q:
            self.close()

        if e.key() == Qt.Key_Escape or e.key() == Qt.Key_P:
            if self.timer.isActive:
                self.timer.stop()
            else:
                self.timer.start(0)
            self.timer.isActive = not self.timer.isActive

        if e.key() == Qt.Key_Left or e.key() == Qt.Key_A:
            self.snake.change_dir("Left")
        if e.key() == Qt.Key_Right or e.key() == Qt.Key_D:
            self.snake.change_dir("Right")
        if e.key() == Qt.Key_Down or e.key() == Qt.Key_S:
            self.snake.change_dir("Down")
        if e.key() == Qt.Key_Up or e.key() == Qt.Key_W:
            self.snake.change_dir("Up")

    # def keyReleaseEvent(self, e):
    # if e.key() == Qt.Key_Left:
    #     self.left = False
    # if e.key() == Qt.Key_Right:
    #     self.right = False
    # if e.key() == Qt.Key_Down:
    #     self.down = False
    # if e.key() == Qt.Key_Up:
    #     self.up = False

    def random_color(self):
        r, g, b = random.randint(0, 255), random.randint(0,
                                                         255), random.randint(
                                                             0, 255)
        a = 255
        r, g, b, a = hex(r)[2:], hex(g)[2:], hex(b)[2:], hex(a)[2:]
        if len(r) == 1:
            r = '0' + r
        if len(g) == 1:
            g = '0' + g
        if len(b) == 1:
            b = '0' + b
        if len(a) == 1:
            a = '0' + a
        hex_code = '#' + r + g + b

        return hex_code

    def update(self):
        self.snake.move()
        self.render()

    def draw_canvas(self):
        self.painter_canvas.fillRect(0, 0, self.display_width,
                                     self.display_height, Qt.white)

    def draw_snake_ebene(self):
        self.brush.setStyle(Qt.SolidPattern)
        self.brush.setColor(QtGui.QColor('green'))
        self.painter_snake.fillRect(0, 0, self.display_width,
                                    self.display_height, Qt.white)
        # self.painter_snake.fillRect(0, 0, self.display_width, self.display_height, Qt.transparent)
        self.painter_snake.setBrush(self.brush)
        self.painter_snake.drawRect(self.snake.x, self.snake.y,
                                    self.snake.width, self.snake.width)

        self.painter_canvas.drawImage(0, 0, self.snake_ebene)

    def draw_background(self):
        self.brush.setStyle(Qt.Dense1Pattern)
        n = 10
        w = self.display_width // n
        h = self.display_height // n
        self.painter_background.setBrush(self.brush)
        for i in range(n):
            for j in range(n):
                color = QColor(self.random_color())
                # color.setAlphaF(random.random())
                self.brush.setColor(color)
                # color.setAlpha(255)
                self.painter_background.setBrush(self.brush)

                self.painter_background.drawRect(i * w, j * h, w, h)

        self.painter_canvas.drawImage(0, 0, self.background)

    def render(self):
        self.draw_canvas()
        # self.draw_background()
        self.draw_snake_ebene()

        self.label.setPixmap(QPixmap.fromImage(self.canvas))
Пример #30
0
    def drawBrushes(self, qp):

        brush = QBrush(Qt.SolidPattern)
        qp.setBrush(brush)
        qp.drawRect(10, 15, 90, 60)

        brush.setStyle(Qt.Dense1Pattern)
        qp.setBrush(brush)
        qp.drawRect(130, 15, 90, 60)

        brush.setStyle(Qt.Dense2Pattern)
        qp.setBrush(brush)
        qp.drawRect(250, 15, 90, 60)

        brush.setStyle(Qt.DiagCrossPattern)
        qp.setBrush(brush)
        qp.drawRect(10, 105, 90, 60)

        brush.setStyle(Qt.Dense5Pattern)
        qp.setBrush(brush)
        qp.drawRect(130, 105, 90, 60)

        brush.setStyle(Qt.Dense6Pattern)
        qp.setBrush(brush)
        qp.drawRect(250, 105, 90, 60)

        brush.setStyle(Qt.HorPattern)
        qp.setBrush(brush)
        qp.drawRect(10, 195, 90, 60)

        brush.setStyle(Qt.VerPattern)
        qp.setBrush(brush)
        qp.drawRect(130, 195, 90, 60)

        brush.setStyle(Qt.BDiagPattern)
        qp.setBrush(brush)
        qp.drawRect(250, 195, 90, 60)
Пример #31
0
    def tip_dialog(self):

        self.tip_dialog = QDialog()
        self.tip_dialog.setObjectName("self.tip_dialog")
        self.tip_dialog.setWindowModality(Qt.ApplicationModal)
        self.tip_dialog.setFixedSize(495, 514)
        palette = QPalette()
        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.WindowText, brush)
        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Text, brush)
        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Base, brush)
        brush = QBrush(QColor(50, 50, 50))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Window, brush)
        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.WindowText, brush)
        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.Text, brush)
        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.Base, brush)
        brush = QBrush(QColor(50, 50, 50))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.Window, brush)
        brush = QBrush(QColor(170, 175, 178))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.WindowText, brush)
        brush = QBrush(QColor(170, 175, 178))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.Text, brush)
        brush = QBrush(QColor(50, 50, 50))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.Base, brush)
        brush = QBrush(QColor(50, 50, 50))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.Window, brush)
        self.tip_dialog.setPalette(palette)
        self.tip_dialog.setAutoFillBackground(False)
        self.tipImage = QLabel(self.tip_dialog)
        self.tipImage.setGeometry(QRect(40, 80, 401, 401))
        self.tipImage.setText("")
        self.tipImage.setPixmap(QPixmap("../resource/Tip.png"))
        self.tipImage.setScaledContents(True)
        self.tipImage.setObjectName("tipImage")
        self.label_2 = QLabel(self.tip_dialog)
        self.label_2.setGeometry(QRect(10, 10, 481, 31))
        palette = QPalette()
        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.WindowText, brush)
        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Text, brush)
        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Base, brush)
        brush = QBrush(QColor(50, 50, 50))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Window, brush)
        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.WindowText, brush)
        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.Text, brush)
        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.Base, brush)
        brush = QBrush(QColor(50, 50, 50))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.Window, brush)
        brush = QBrush(QColor(170, 175, 178))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.WindowText, brush)
        brush = QBrush(QColor(170, 175, 178))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.Text, brush)
        brush = QBrush(QColor(50, 50, 50))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.Base, brush)
        brush = QBrush(QColor(50, 50, 50))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.Window, brush)
        self.label_2.setPalette(palette)
        font = QFont()
        font.setPointSize(12)
        font.setBold(True)
        font.setWeight(75)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.label_3 = QLabel(self.tip_dialog)
        self.label_3.setGeometry(QRect(10, 30, 441, 31))
        font = QFont()
        font.setPointSize(12)
        font.setBold(True)
        font.setWeight(75)
        self.label_3.setFont(font)
        self.label_3.setObjectName("label_3")
        self.label_4 = QLabel(self.tip_dialog)
        self.label_4.setGeometry(QRect(10, 50, 411, 31))
        font = QFont()
        font.setPointSize(12)
        font.setBold(True)
        font.setWeight(75)
        self.label_4.setFont(font)
        self.label_4.setObjectName("label_4")
        self.continueB = QPushButton(self.tip_dialog)
        self.continueB.setGeometry(QRect(380, 470, 103, 31))
        self.continueB.setObjectName("continueB")
        self.cancelB = QPushButton(self.tip_dialog)
        self.cancelB.setGeometry(QRect(10, 470, 103, 31))
        self.cancelB.setObjectName("cancelB")
        self.pushButton = QPushButton(self.tip_dialog)
        self.pushButton.setGeometry(QRect(430, 60, 41, 21))
        palette = QPalette()
        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.WindowText, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Button, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Light, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Midlight, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Dark, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Mid, brush)
        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Text, brush)
        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.BrightText, brush)
        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.ButtonText, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Base, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Window, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Shadow, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.AlternateBase, brush)
        brush = QBrush(QColor(255, 255, 220))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.ToolTipBase, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.ToolTipText, brush)
        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.WindowText, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.Button, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.Light, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.Midlight, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.Dark, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.Mid, brush)
        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.Text, brush)
        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.BrightText, brush)
        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.ButtonText, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.Base, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.Window, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.Shadow, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.AlternateBase, brush)
        brush = QBrush(QColor(255, 255, 220))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.ToolTipBase, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.ToolTipText, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.WindowText, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.Button, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.Light, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.Midlight, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.Dark, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.Mid, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.Text, brush)
        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.BrightText, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.ButtonText, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.Base, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.Window, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.Shadow, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.AlternateBase, brush)
        brush = QBrush(QColor(255, 255, 220))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.ToolTipBase, brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.ToolTipText, brush)
        self.pushButton.setPalette(palette)
        self.pushButton.setFocusPolicy(Qt.NoFocus)
        self.pushButton.setContextMenuPolicy(Qt.NoContextMenu)
        self.pushButton.setFlat(False)
        self.pushButton.setObjectName("pushButton")

        self.tip_retranslateUi(self.tip_dialog)
        self.cancelB.clicked.connect(self.tip_dialog.reject)
        QMetaObject.connectSlotsByName(self.tip_dialog)
        self.continueB.clicked.connect(self.startMessage)

        self.tip_dialog.exec_()
Пример #32
0
                             QGraphicsScene,
                             QGraphicsView,
                             QGroupBox,
                             QVBoxLayout,
                             )

from .settings import Config, FormInt
from .utils import convert_name_to_color, LINE_WIDTH

lg = getLogger(__name__)

NoPen = QPen()
NoPen.setStyle(Qt.NoPen)

NoBrush = QBrush()
NoBrush.setStyle(Qt.NoBrush)

STAGES = {'Wake': {'pos0': 5, 'pos1': 25, 'color': Qt.black},
          'Movement': {'pos0': 5, 'pos1': 25, 'color': Qt.darkGray},
          'REM': {'pos0': 10, 'pos1': 20, 'color': Qt.magenta},
          'NREM1': {'pos0': 15, 'pos1': 15, 'color': Qt.cyan},
          'NREM2': {'pos0': 20, 'pos1': 10, 'color': Qt.blue},
          'NREM3': {'pos0': 25, 'pos1': 5, 'color': Qt.darkBlue},
          'Undefined': {'pos0': 0, 'pos1': 30, 'color': Qt.gray},
          'Unknown': {'pos0': 30, 'pos1': 0, 'color': NoBrush},
          }

BARS = {'markers': {'pos0': 15, 'pos1': 10, 'tip': 'Markers in Dataset'},
        'annot': {'pos0': 30, 'pos1': 10,
                  'tip': 'Annotations (bookmarks and events)'},
        'stage': {'pos0': 45, 'pos1': 30, 'tip': 'Sleep Stage'},
Пример #33
0
    def drawBrushes(self, qp):
      
        brush = QBrush(Qt.SolidPattern)
        qp.setBrush(brush)
        qp.drawRect(10, 15, 90, 60)

        brush.setStyle(Qt.Dense1Pattern)
        qp.setBrush(brush)
        qp.drawRect(130, 15, 90, 60)

        brush.setStyle(Qt.Dense2Pattern)
        qp.setBrush(brush)
        qp.drawRect(250, 15, 90, 60)

        brush.setStyle(Qt.Dense3Pattern)
        qp.setBrush(brush)
        qp.drawRect(10, 105, 90, 60)

        brush.setStyle(Qt.DiagCrossPattern)
        qp.setBrush(brush)
        qp.drawRect(10, 105, 90, 60)

        brush.setStyle(Qt.Dense5Pattern)
        qp.setBrush(brush)
        qp.drawRect(130, 105, 90, 60)

        brush.setStyle(Qt.Dense6Pattern)
        qp.setBrush(brush)
        qp.drawRect(250, 105, 90, 60)

        brush.setStyle(Qt.HorPattern)
        qp.setBrush(brush)
        qp.drawRect(10, 195, 90, 60)

        brush.setStyle(Qt.VerPattern)
        qp.setBrush(brush)
        qp.drawRect(130, 195, 90, 60)

        brush.setStyle(Qt.BDiagPattern)
        qp.setBrush(brush)
        qp.drawRect(250, 195, 90, 60)
Пример #34
0
    def drawBrushes(self, qp):
        brush = QBrush(
            Qt.SolidPattern
        )  # создание объекта и определ параметра (сплошная заливка)
        qp.setBrush(brush)
        qp.drawRect(10, 15, 90, 60)

        brush.setStyle(Qt.Dense1Pattern)
        qp.setBrush(brush)
        qp.drawRect(130, 15, 90, 60)

        brush.setStyle(Qt.Dense2Pattern)
        qp.setBrush(brush)
        qp.drawRect(250, 15, 90, 60)

        brush.setStyle(Qt.Dense3Pattern)
        qp.setBrush(brush)
        qp.drawRect(10, 105, 90, 60)

        brush.setStyle(Qt.DiagCrossPattern)
        col = QColor(250, 2, 26)  # задаем фон
        qp.setBrush(col)  # задаем фон
        qp.drawRect(10, 105, 90, 60)  # задаем фон
        qp.setBrush(brush)  # рисуем узор поверх
        qp.drawRect(10, 105, 90, 60)  # рисуем узор поверх

        brush.setStyle(Qt.Dense5Pattern)
        qp.setBrush(brush)
        qp.drawRect(130, 105, 90, 60)

        brush.setStyle(Qt.Dense6Pattern)
        qp.setBrush(brush)
        qp.drawRect(250, 105, 90, 60)

        brush.setStyle(Qt.HorPattern)
        qp.setBrush(brush)
        qp.drawRect(10, 195, 90, 60)

        brush.setStyle(Qt.VerPattern)
        qp.setBrush(brush)
        qp.drawRect(130, 195, 90, 60)

        brush.setStyle(Qt.BDiagPattern)
        qp.setBrush(brush)
        qp.drawRect(250, 195, 90, 60)
Пример #35
0
    def drawBrushes(self, qp):
        # 创建了一个笔刷对象,添加笔刷样式,然后调用`drawRect()`方法画图。
        brush = QBrush(Qt.SolidPattern)
        qp.setBrush(brush)
        # drawRect的参数分别是:前两个参数是左上角端点的位置,后两个是长和宽
        qp.drawRect(10, 325, 90, 60)

        brush.setStyle(Qt.Dense1Pattern)
        qp.setBrush(brush)
        qp.drawRect(130, 325, 90, 60)

        brush.setStyle(Qt.Dense2Pattern)
        qp.setBrush(brush)
        qp.drawRect(250, 325, 90, 60)

        brush.setStyle(Qt.DiagCrossPattern)
        qp.setBrush(brush)
        qp.drawRect(10, 405, 90, 60)

        brush.setStyle(Qt.Dense5Pattern)
        qp.setBrush(brush)
        qp.drawRect(130, 405, 90, 60)

        brush.setStyle(Qt.Dense6Pattern)
        qp.setBrush(brush)
        qp.drawRect(250, 405, 90, 60)

        brush.setStyle(Qt.HorPattern)
        qp.setBrush(brush)
        qp.drawRect(10, 485, 90, 60)

        brush.setStyle(Qt.VerPattern)
        qp.setBrush(brush)
        qp.drawRect(130, 485, 90, 60)

        brush.setStyle(Qt.BDiagPattern)
        qp.setBrush(brush)
        qp.drawRect(250, 485, 90, 60)
Пример #36
0
    def onCellChanged(self, row, column):
        if column in (0, 1):
            item1 = self.tableWidget.item(row, 0)
            if item1 is not None:
                item1 = item1.text().replace(' ', '')
                try:
                    ipaddress.ip_address(item1)
                except ValueError:
                    if item1 == '':
                        col0 = 2
                    else:
                        col0 = 0
                else:
                    col0 = 1
            else:
                col0 = 2

            item2 = self.tableWidget.item(row, 1)
            if item2 is not None:
                item2 = item2.text().replace(' ', '')
                if item2.isnumeric() and int(item2) <= 65535:
                    col1 = 1
                elif item2 == '':
                    col1 = 2
                else:
                    col1 = 0
            else:
                col1 = 2

            if (col0 == 0 and col1 == 0)\
                    or (col0 == 2 and col1 == 2):
                backgr = QTableWidgetItem()
                brush = QBrush(QColor(255, 0, 0))
                brush.setStyle(Qt.SolidPattern)
                backgr.setBackground(brush)
                item = QTableWidgetItem()
                self.tableWidget.setItem(row, 3, item)
                item.setFlags(Qt.ItemIsEnabled)
                item.setBackground(brush)

            if (col0 == 0 and (col1 == 1 or col1 == 2))\
                    or (col1 == 0 and (col0 == 1 or col0 == 2)):
                backgr = QTableWidgetItem()
                brush = QBrush(QColor(255, 127, 0))
                brush.setStyle(Qt.SolidPattern)
                backgr.setBackground(brush)
                item = QTableWidgetItem()
                self.tableWidget.setItem(row, 3, item)
                item.setFlags(Qt.ItemIsEnabled)
                item.setBackground(brush)

            if (col0 == 1 and (col1 == 1 or col1 == 2))\
                    or (col1 == 1 and (col0 == 1 or col0 == 2)):
                backgr = QTableWidgetItem()
                brush = QBrush(QColor(0, 255, 0))
                brush.setStyle(Qt.SolidPattern)
                backgr.setBackground(brush)
                item = QTableWidgetItem()
                self.tableWidget.setItem(row, 3, item)
                item.setFlags(Qt.ItemIsEnabled)
                item.setBackground(brush)
        else:
            pass
Пример #37
0
from pyqtgraph.functions import mkPen
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QColor, QBrush

# TODO: Pick color scheme

# RPE Table
_RPE_IDEAL_ALPHA = 140
_RPE_UNDESIRABLE_ALPHA = 120

RpeBrushIdeal = QBrush(QColor(255, 255, 0, _RPE_IDEAL_ALPHA))
RpeBrushIdeal.setStyle(Qt.SolidPattern)

RpeBrushUndesirable = QBrush(QColor(255, 0, 0, _RPE_UNDESIRABLE_ALPHA))
RpeBrushUndesirable.setStyle(Qt.SolidPattern)

bw_color_cols = ['Diff', 'Goal_Diff']
BW_TABLE_ALPHA = 120
LOG_START = 90
# TODO: Refactor other brushes, pick color scheme
green_brush = QBrush(QColor(0, 255, 0, BW_TABLE_ALPHA))
green_brush.setStyle(Qt.SolidPattern)

red_brush = QBrush(QColor(255, 0, 0, BW_TABLE_ALPHA))
red_brush.setStyle(Qt.SolidPattern)

blue_brush = QBrush(QColor(0, 0, 255, 120))
blue_brush.setStyle(Qt.SolidPattern)

gray_brush = QBrush(QColor(200, 200, 200, 70))
gray_brush.setStyle(Qt.SolidPattern)