我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PySide.QtGui.QColor()。
def setupUi(self): """Bruh""" self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setGeometry(50, 50, 600, 300) self.setWindowTitle("ZeZe's TWTools - Backtiming Calculator") self.setWindowIcon(QtGui.QIcon(resource_path("images/icon.png"))) """Background color""" self.backgroundPalette = QtGui.QPalette() self.backgroundColor = QtGui.QColor(217, 204, 170) self.backgroundPalette.setColor( QtGui.QPalette.Background, self.backgroundColor) self.setPalette(self.backgroundPalette) """Main layout & return to main menu button""" self.verticalLayout = QtGui.QVBoxLayout(self) self.buttonLayout = QtGui.QHBoxLayout(self) self.verticalLayout.addLayout(self.buttonLayout) self.returnButton = QtGui.QPushButton(" Return to the Main Menu ", self) self.returnButton.clicked.connect(self.return_function) self.buttonLayout.addWidget(self.returnButton) self.buttonSpacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.buttonLayout.addItem(self.buttonSpacer)
def paintEvent(self, event): painter = QtGui.QPainter(self) painter.setRenderHint(QtGui.QPainter.Antialiasing) parent = self.parentWidget() pieRect = QtCore.QRect(1, 1, self.width()-2, self.height()-2) startAngle = 0 * 16 if self.currentIndex() == 0: # STATUS = WAITING painter.drawEllipse(pieRect) elif self.currentIndex() == 1: # STATUS = IN PROGGRESS painter.setPen(QtGui.QColor(0,0,0,0)) painter.setBrush(QtGui.QColor(255, 140, 30)) startAngle = 90 * 16 spanAngle = self.currentIndex() * 270 * 16 painter.drawPie(pieRect, startAngle, spanAngle) elif self.currentIndex() == 2: # STATUS = FINISHED painter.setPen(QtGui.QColor(0,0,0,0)) painter.setBrush(QtGui.QColor('darkGreen')) spanAngle = self.currentIndex() * 360 * 16 painter.drawPie(pieRect, startAngle, spanAngle)
def __init__(self, item, timeline_range, *args, **kwargs): super(_BaseItem, self).__init__(*args, **kwargs) self.item = item self.timeline_range = timeline_range self.setFlags(QtGui.QGraphicsItem.ItemIsSelectable) self.setBrush( QtGui.QBrush(QtGui.QColor(180, 180, 180, 255)) ) self.source_in_label = QtGui.QGraphicsSimpleTextItem(self) self.source_out_label = QtGui.QGraphicsSimpleTextItem(self) self.source_name_label = QtGui.QGraphicsSimpleTextItem(self) self._add_markers() self._set_labels()
def ChangeColors(self): """ Clustered Order is the sorted order of different brain regions based on the communities detected """ self.sortDataStructure(self.Order,self.Brain_Regions) self.setVerticalHeaderLabels(self.ClusteredOrder) self.setHorizontalHeaderLabels(['\n'.join(name) for name in self.ClusteredOrder]) for i in range(len(self.correlationTable.header)): for j in range(len(self.correlationTable.header)): table_item = self.item(i,j) t = self.ColorNumpyArray[self.sortedOrder[i],self.sortedOrder[j]] table_item.setBackground(QtGui.QColor(*t)) table_item.setToolTip("%s,%s,%g" % (self.Brain_Regions[self.sortedOrder[i]] ,self.Brain_Regions[self.sortedOrder[j]],self.correlationTable.data[self.sortedOrder[i], self.sortedOrder[j]])) self.verticalHeader() self.horizontalHeader()
def format(color, style=None): """ Return a QTextCharFormat with the given attributes. :param color: The color to format the text. :param style: [optional] The styling for the text. """ _color = QtGui.QColor() _color.setNamedColor(color) _format = QtGui.QTextCharFormat() _format.setForeground(_color) if style is not None and 'bold' in style: _format.setFontWeight(QtGui.QFont.Bold) if style is not None and 'italic' in style: _format.setFontItalic(True) return _format # Syntax styles that can be shared by all languages
def paintEvent(self, event): painter = QPainter() painter.begin(self) painter.setRenderHint(QPainter.Antialiasing) painter.fillRect(event.rect(), QBrush(QColor(127, 127, 127, 127))) painter.setPen(QPen(Qt.NoPen)) for i in range(6): if int(self.counter / 10) % 6 == i: factor = self.counter % 10 if factor >= 5: factor = 5 - (self.counter % 5) painter.setBrush(QBrush(QColor(95 + factor * 32, 127, 127))) else: painter.setBrush(QBrush(QColor(127, 127, 127))) painter.drawEllipse( self.width() / 2 + 30 * math.cos(2 * math.pi * i / 6.0) - 10, self.height() / 2 + 30 * math.sin(2 * math.pi * i / 6.0) - 10, 20, 20) painter.end()
def CreateTrackingNodes(self, partitionValues): i = 0 self.counter = self.counter+1 self.presentNodeObjects = [] sceneRect = self.sceneRect() # Create the nodes which are rated in the way that it is organized # Just create one layer of the nodes here!! for now for communities, sub_communities in partitionValues.items(): i = i + 1 node_value=CommunityGraphNode(self,communities, sub_communities) node_value.setPos(sceneRect.left() + self.variableWidth*100, i*40) self.presentNodeObjects.append(node_value) self.scene.addItem(node_value) if self.first: value = len(partitionValues.values()) self.first = False #* self.NewCommunitiesToBeAssigned = [] self.NewCommunitiesToBeAssigned = deque([j for i,j in enumerate(self.distinguishableColors) if i > (13)]) for i in self.presentNodeObjects: color = self.NewCommunitiesToBeAssigned.popleft() colorNew = QtGui.QColor(color[0],color[1],color[2]) i.PutColor(colorNew)
def ChangeColors(self): """ Clustered Order is the sorted order of different brain regions based on the communities detected """ """Calling the Parent Method for Sorting the cells""" self.sortDataStructure(self.Order,self.Brain_Regions) """Sorting the header labels vertical and horizontalHeader""" self.setVerticalHeaderLabels(self.ClusteredOrder) self.setHorizontalHeaderLabels(['\n'.join(name) for name in self.ClusteredOrder]) for i in range(len(self.correlationTable.header)): for j in range(len(self.correlationTable.header)): table_item = self.item(i,j) if (self.GraphDataStructure().ThresholdData[self.sortedOrder[i]][self.sortedOrder[j]] != 0) and self.sortedValues[i] == self.sortedValues[j]: table_item.setBackground(QtGui.QColor(*self.colors[self.sortedOrder[i]])) else: table_item.setBackground(QtGui.QColor(QtCore.Qt.white)) table_item.setToolTip("%s,%s,%g" % (self.Brain_Regions[self.sortedOrder[i]] ,self.Brain_Regions[self.sortedOrder[j]],self.correlationTable.data[self.sortedOrder[i], self.sortedOrder[j]])) self.verticalHeader() self.horizontalHeader()
def PutColor(self,colorvalue, alphaValue = 255, AlphaDraw = False): self.colorvalue = colorvalue if self.Glyph: self.ColorQ.append(self.CommunityColor) self.CommunityColor = QtGui.QColor(colorvalue) # set the graph nodes to the transparent if alphaValue == None: self.CommunityColor.setAlpha(0) self.opacity = 0 elif not(alphaValue==-1): if AlphaDraw: self.CommunityColor.setAlpha(alphaValue) else: self.CommunityColor.setAlpha(255) self.opacity = alphaValue self.NodeCommunityColor = True self.update()
def add_data_to_table(self, route): self.tableWidget_path.setRowCount(len(route)) for i, row in enumerate(route): for j, col in enumerate(row): item = QtGui.QTableWidgetItem("{}".format(col)) self.tableWidget_path.setItem(i, j, item) if j in [1, 2]: self.tableWidget_path.item(i, j).setTextAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) if row[1] == "HS": color = QtGui.QColor(223, 240, 216) elif row[1] == "LS": color = QtGui.QColor(252, 248, 227) elif row[1] == "NS": color = QtGui.QColor(242, 222, 222) else: color = QtGui.QColor(210, 226, 242) if j == 3 and "wormhole" in col: self.tableWidget_path.item(i, j).setIcon(self.icon_wormhole) self.tableWidget_path.item(i, j).setBackground(color) self.tableWidget_path.item(i, j).setForeground(QtGui.QColor(0, 0, 0))
def catalogChange(self,*args): while self.form.Reference.count(): self.form.Reference.removeItem(0) for reference in self.form.Catalog.itemData(args[0]): red = QtGui.QPixmap(16, 16) red.fill(QtGui.QColor("red")) green = QtGui.QPixmap(16, 16) green.fill(QtGui.QColor("green")) if self.is_available(self.form.Catalog.currentText(),reference): color = green else: color = red self.form.Reference.addItem(color,reference) #item.setStyleSheet("color: green")
def drawBars(self, painter): size = self.size() width = size.width() height = size.height() bar_width = float(width - self.padding) / self.bars_number color = QtGui.QColor(0, 0, 0) painter.setPen(color) painter.setBrush(color) painter.drawRect(0, 0, width, height) for bar, value in enumerate(self.bars): bar_height = (height - self.padding) * value / self.resolution if not bar_height: bar_height = 1 painter.setBrush(self.barColor(bar)) painter.drawRect( bar * bar_width + self.padding, height - bar_height, bar_width - self.padding, bar_height - self.padding)
def createnewwire(widget): '''new wire for next drawing''' ef=widget.ef w=App.ActiveDocument.addObject("Part::Feature","A Drawing on " + ef.objname + ": "+ ef.subelement +"#") w.Shape=Part.Shape() wam=App.ActiveDocument.addObject("Part::Feature","YY Drawing on " + ef.objname + ": "+ ef.subelement +"#") wam.Shape=Part.Shape() if 10: c=PySide.QtGui.QColorDialog.getColor(QtGui.QColor(random.randint(10,255),random.randint(10,255),random.randint(10,255))) w.ViewObject.LineColor=(1.0/255*c.red(),1.0/255*c.green(),1.0/255*c.blue()) w.ViewObject.PointColor=(1.0/255*c.red(),1.0/255*c.green(),1.0/255*c.blue()) else: w.ViewObject.LineColor=(random.random(),random.random(),random.random()) ef.wire=w ef.wirem=wam ef.pts=[] ## dialog fpr facedrwaing options
def stopRead(self): """ Purpose: Respond to disconnect button being clicked -- disconnect from the port, be it serial or socket Input: None Output: None """ self.connectedPort.close() # Update GUI self.label_serialStatus.setText(QtGui.QApplication.translate("MainWindow", "Port closed", None, QtGui.QApplication.UnicodeUTF8)) palette = QtGui.QPalette() palette.setColor(QtGui.QPalette.Foreground, QColor(242, 86, 77)) # Red self.label_serialStatus.setPalette(palette)
def saveLogToggled(self): """ Purpose: Respond to the user toggling the save log button (create a new output data log as appropriate) Input: None Output: Creates a log file on disk if toggling on """ if self.checkBox_saveLog.isChecked(): self.setupOutputLog() else: # Update the GUI for the log file - not saving self.textBrowser_savingToLogFile.setText("Not saving to log file") palette = QtGui.QPalette() palette.setColor(QtGui.QPalette.Text, QColor(242, 86, 77)) # Red self.textBrowser_savingToLogFile.setPalette(palette)
def compareFiles(self,*args): color=QtGui.QColor(255,0,0) it = QtGui.QTreeWidgetItemIterator(self.publishesTree) for i in it: if i.value().childCount()==0: serverPath=self.convertTreePathToServerPath(self.getTreePathFromItem(i.value())) localPath=serverPath.replace("P:",self.localDrive) frames=[] if os.path.exists(localPath): for file in os.listdir(localPath+'/exr'): if os.path.isfile(localPath+'/exr/'+file): print file frames.append(str(int(file.split(".")[1]))) frames.sort() i.value().setForeground(0,color) i.value().setText(2,",".join(frames))
def setPaletteFromDct(dct): palette = QtGui.QPalette() for role in roles: for group in groups: color = QtGui.QColor(dct['%s:%s' % (role, group)]) qGrp = getattr(QtGui.QPalette, group) qRl = getattr(QtGui.QPalette, role) palette.setColor(qGrp, qRl, color) QtGui.QApplication.setPalette(palette)
def setupUi(self): """Bruh""" self.setGeometry(50, 50, 450, 250) self.setWindowTitle("ZeZe's TWTools - Updating Servers") self.setWindowIcon(QtGui.QIcon(resource_path("images/icon.png"))) """Background color""" self.backgroundPalette = QtGui.QPalette() self.backgroundColor = QtGui.QColor(217, 204, 170) self.backgroundPalette.setColor(QtGui.QPalette.Background, self.backgroundColor) self.setPalette(self.backgroundPalette) """Layout""" self.verticalLayout = QtGui.QVBoxLayout(self) self.text = QtGui.QLabel("Updating server list:") self.verticalLayout.addWidget(self.text) """Download bar""" self.progress_bar = QtGui.QProgressBar(self) self.progress_bar.setMinimum(0) self.progress_bar.setMaximum(27) self.progress_bar.setValue(0) self.progress_bar.setFormat("%v / %m") self.verticalLayout.addWidget(self.progress_bar) """Text browser for progress""" self.progress_text = QtGui.QTextBrowser(self) self.verticalLayout.addWidget(self.progress_text) """Button""" self.horizontalLayout = QtGui.QHBoxLayout(self) self.verticalLayout.addLayout(self.horizontalLayout) self.Spacer = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(self.Spacer) self.cancelButton = QtGui.QPushButton("Cancel") self.horizontalLayout.addWidget(self.cancelButton) self.cancelButton.clicked.connect(self.cancel_function)
def set_marker(self,point, bot): scene_point = point if self.marker_set: self.scene.removeItem(self.marker_ellipse) self.scene.removeItem(self.marker_line_h) self.scene.removeItem(self.marker_line_v) color = QtGui.QColor() if bot: color = QtGui.QColor(QtCore.Qt.red) else: color = QtGui.QColor(QtCore.Qt.darkGreen) color.setAlpha(100) pen = QtGui.QPen() pen.setWidth(2) pen.setColor(color) self.marker_ellipse = self.scene.addEllipse(scene_point.x()-10,scene_point.y()-10,20,20,pen); self.marker_line_h = self.scene.addLine(scene_point.x()-10,scene_point.y(),scene_point.x()+10,scene_point.y(),pen); self.marker_line_v = self.scene.addLine(scene_point.x(),scene_point.y()-10,scene_point.x(),scene_point.y()+10,pen); self.marker_set = True if bot: self.svg_item_bot.setVisible(True) self.svg_item_top.setVisible(False) if not self.is_flipped: self.scale(-1,1) self.is_flipped = True else: self.svg_item_bot.setVisible(False) self.svg_item_top.setVisible(True) if self.is_flipped: self.scale(-1,1) self.is_flipped = False
def getRGB(param): color = QtGui.QColor(getParam(param,16753920)>>8) r = float(color.red()/255.0) g = float(color.green()/255.0) b = float(color.blue()/255.0) col = (r,g,b,0.0) return col
def paintEvent(self, event): '''Paint the button grey if not highlighted, else yellow''' painter = QtGui.QPainter(self) colour = QtGui.QColor(247, 147, 30, 150) gradient = QtGui.QLinearGradient(QtCore.QPoint(0,0), QtCore.QPoint(self.width()/2, 0)) gradient.setColorAt(0, QtCore.Qt.transparent) gradient.setColorAt(1, colour) gradient.setSpread(QtGui.QGradient.ReflectSpread) painter.setBrush(QtGui.QBrush(gradient)) painter.setPen(QtCore.Qt.transparent) rect = QtCore.QRect(0,0,self.width(),self.height()) painter.drawRect(rect)
def __init__(self, parent=None): super(PriorityWidget, self).__init__(parent) self.color = QtGui.QColor(247, 147, 30, 255) self.font = QtGui.QFont('Helvetica', 12, QtGui.QFont.Bold) self.setToolTip('<b>priority</b><br>use either:<ul><li>LMB to increase - RMB to decrease</li><li>alt+LMB drag to change value</li><li>MMB drag to change value</li></ul><i>move mouse away after changing value<br>to trigger re-sorting</i>') self.active = False self.mouseOver = False self.value = 0 self.allowDrag = False self.setFocusPolicy(QtCore.Qt.TabFocus) self.indicator = DragIndicator(self) self.indicator.setVisible(False) self.indicator.move(0, 15)
def __init__(self, parent=None): super(StatusWidgetBar, self).__init__(parent) self.setToolTip('<b>status</b><br>click to edit') self.addItems(['waiting', 'in progress', 'finished']) self.active = False self.colWaiting = QtGui.QColor(180, 100, 10) self.colInProgress = QtGui.QColor(255, 140, 30) self.colFinished = QtGui.QColor('darkGreen')
def __init__(self, parent=None): super(DeleteWidget, self).__init__(parent) self.size = QtCore.QSize(20, 20) self.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) self.setToolTip('permanently delete this task') self.padding = 7 self.active = False self.inactiveColor = QtGui.QColor(180, 50, 0) self.activeColor = self.inactiveColor.lighter()
def itemChange(self, change, value): if change == QtGui.QGraphicsItem.ItemSelectedHasChanged: self.setPen( QtGui.QColor(0, 255, 0, 255) if self.isSelected() else QtGui.QColor(0, 0, 0, 255) ) self.setZValue( self.zValue() + 1 if self.isSelected() else self.zValue() - 1 ) return super(_BaseItem, self).itemChange(change, value)
def __init__(self, *args, **kwargs): super(GapItem, self).__init__(*args, **kwargs) self.setBrush( QtGui.QBrush(QtGui.QColor(100, 100, 100, 255)) ) self.source_name_label.setText('GAP')
def __init__(self, item, timeline_range, rect, *args, **kwargs): rect.setHeight(TRANSITION_HEIGHT) super(TransitionItem, self).__init__( item, timeline_range, rect, *args, **kwargs ) self.setBrush( QtGui.QBrush(QtGui.QColor(237, 228, 148, 255)) ) self.setY(TRACK_HEIGHT - TRANSITION_HEIGHT) self.setZValue(2) # add extra bit of shading shading_poly_f = QtGui.QPolygonF() shading_poly_f.append(QtCore.QPointF(0, 0)) shading_poly_f.append(QtCore.QPointF(rect.width(), 0)) shading_poly_f.append(QtCore.QPointF(0, rect.height())) shading_poly = QtGui.QGraphicsPolygonItem(shading_poly_f, parent=self) shading_poly.setBrush(QtGui.QBrush(QtGui.QColor(0, 0, 0, 30))) try: shading_poly.setPen(QtCore.Qt.NoPen) except TypeError: shading_poly.setPen(QtCore.Qt.transparent)
def __init__(self, *args, **kwargs): super(ClipItem, self).__init__(*args, **kwargs) self.setBrush(QtGui.QBrush(QtGui.QColor(168, 197, 255, 255))) self.source_name_label.setText(self.item.name)
def __init__(self, track, *args, **kwargs): super(TrackWidget, self).__init__(*args, **kwargs) self.track = track self.setBrush(QtGui.QBrush(QtGui.QColor(43, 52, 59, 255))) self._populate()
def __init__(self, marker, *args, **kwargs): self.item = marker poly = QtGui.QPolygonF() poly.append(QtCore.QPointF(0.5 * MARKER_SIZE, -0.5 * MARKER_SIZE)) poly.append(QtCore.QPointF(0.5 * MARKER_SIZE, 0.5 * MARKER_SIZE)) poly.append(QtCore.QPointF(0, MARKER_SIZE)) poly.append(QtCore.QPointF(-0.5 * MARKER_SIZE, 0.5 * MARKER_SIZE)) poly.append(QtCore.QPointF(-0.5 * MARKER_SIZE, -0.5 * MARKER_SIZE)) super(Marker, self).__init__(poly, *args, **kwargs) self.setFlags(QtGui.QGraphicsItem.ItemIsSelectable) self.setBrush(QtGui.QBrush(QtGui.QColor(121, 212, 177, 255)))
def itemChange(self, change, value): if change == QtGui.QGraphicsItem.ItemSelectedHasChanged: self.setPen( QtGui.QColor(0, 255, 0, 255) if self.isSelected() else QtGui.QColor(0, 0, 0, 255) ) return super(Marker, self).itemChange(change, value)
def __init__(self, *args, **kwargs): super(TimeSlider, self).__init__(*args, **kwargs) self.setBrush(QtGui.QBrush(QtGui.QColor(64, 78, 87, 255)))
def __init__(self, composition, *args, **kwargs): super(CompositionWidget, self).__init__(*args, **kwargs) self.composition = composition self.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(64, 78, 87, 255))) self._adjust_scene_size() self._add_time_slider() self._add_tracks() self._add_markers()
def __init__(self, graphWidget, sourceNode, destNode, counter, sourceId, destId, MaxValue,weight=100,ForCommunities=False,): QtGui.QGraphicsItem.__init__(self) self.setAcceptHoverEvents(True) self.EdgeThreshold = MaxValue - 0.01 self.ColorEdgesFlag = False self.index = counter self.Alpha = 0.2 self.sourceId = sourceId self.destId = destId self.ColorMap = True self.ForCommunities= ForCommunities self.HighlightedColorMap = False self.communityWeight = weight self.edgeThickness = 1 self.thickHighlightedEdges = 3 self.ColorOnlySelectedNodesFlag =False if math.isnan(weight): weight = 1 self.weight = weight if ForCommunities: self.communtiyColor = ColorToInt((0,0,0,255)) self.communtiyColor1 = QtGui.QColor(self.communtiyColor) self.setToolTip(str("InterModular Correlation Strength: "+str(weight)+"\n"+"Source Community: "+str(sourceId)+"\nDestination Community: "+str(destId))) self.sourcePoint = QtCore.QPointF() self.destPoint = QtCore.QPointF() self.graph = weakref.ref(graphWidget) self.source = weakref.ref(sourceNode) self.dest = weakref.ref(destNode) self.EdgeColor = QtGui.QColor(self.graph().EdgeColor[self.index]) self.source().addEdge(self)
def PutColor(self,colorvalue): self.colorvalue = colorvalue self.CommunityColor = QtGui.QColor(colorvalue) self.NodeCommunityColor = True
def setOpaqueNodes(self): self.colorTransparency = False self.nodeColor = QtGui.QColor(self.graph().DataColor[self.counter]) if self.NodeCommunityColor: self.CommunityColor.setAlpha(255) else: self.nodeColor.setAlpha(255) self.update()
def unsetOpaqueNodes(self): self.colorTransparency = True self.nodeColor = QtGui.QColor(self.graph().DataColor[self.counter]) if not(self.setTransp): return if self.NodeCommunityColor: self.CommunityColor.setAlpha(25) else: self.nodeColor.setAlpha(25) self.update()
def PutColor(self,colorvalue,alphaValue = -1): self.colorvalue = colorvalue self.CommunityColor = QtGui.QColor(colorvalue) self.NodeCommunityColor = True self.update()
def PutColor(self,colorvalue): # print "Value", self.Nodeidss self.colorvalue = colorvalue self.CommunityColor = QtGui.QColor(colorvalue) self.update()
def UpdateColorsInElectrodeView(self, nodelist, Offset = 0): ElectrodeViewObjectDummy = self.electrode.SmallMultipleElectrode[1] for i in nodelist: try: ElectrodeViewNumberToUpdate = self.AggregateHashmap[i['timestep']] except KeyError: continue # getting the electrode view number ElectrodeViewObject = self.electrode.SmallMultipleElectrode[ElectrodeViewNumberToUpdate] assert ElectrodeViewObject.ChunkNo == ElectrodeViewNumberToUpdate # get the elements in the community defined by that CommunityNumber = i['OriginalAssignmentValue'] Elements = i['Elements'] Color = i['color'].replace("rgb(", "").replace(")", "").replace(" ", "").split(',') Color = map(int, Color) for element in Elements: ActualElectrodeNumber = self.electrode.ElectrodeIds[element] norm = ElectrodeViewObject.ElectrodeOpacity[element].normalize(i['timestep'], ActualElectrodeNumber) ElectrodeViewObject.NodeIds[element].PutFinalColors(norm[0],norm[1], QtGui.QColor(Color[0],Color[1],Color[2]),i['timestep'],CommunityNumber,ElectrodeViewObjectDummy.slices) assert ElectrodeViewObject.NodeIds[element].counter == element ElectrodeViewObject.NodeIds[element].update()
def __init__(self, graphWidget, sourceNode, destNode, counter, sourceId, destId, MaxValue,weight=1,ForCommunities=False,): QtGui.QGraphicsItem.__init__(self) self.setAcceptHoverEvents(False) self.EdgeThreshold = MaxValue - 0.01 self.ColorEdgesFlag = False self.index = counter self.Alpha = 0.2 self.sourceId = sourceId self.destId = destId self.ColorMap = True self.ForCommunities= ForCommunities self.HighlightedColorMap = False self.communityWeight = weight self.edgeThickness = 1 self.thickHighlightedEdges = 3 self.ColorOnlySelectedNodesFlag =False if math.isnan(weight): weight = 0 self.weight = weight if ForCommunities: self.communtiyColor = ColorToInt((0,0,0,255)) self.communtiyColor1 = QtGui.QColor(self.communtiyColor) self.setToolTip(str("InterModular Strength: "+"{0:.2f}".format(weight))) self.sourcePoint = QtCore.QPointF() self.destPoint = QtCore.QPointF() self.graph = weakref.ref(graphWidget) self.source = weakref.ref(sourceNode) self.dest = weakref.ref(destNode) self.EdgeColor = QtGui.QColor(self.graph().EdgeColor[self.index]) self.source().addEdge(self)
def PutTextColor(self,colorvalue): self.TextColor = colorvalue self.CommunityTextColor = QtGui.QColor(colorvalue) self.update()
def PutColor(self,colorvalue): self.colorvalue = colorvalue self.CommunityColor = QtGui.QColor(colorvalue) self.NodeCommunityColor = True self.update()
def PutFinalColors(self,opacity,actualValue, colorvalue,timesterange,\ communityMemebership,slices= 4, alphaValue=255,\ AllFourColors = None, AlphaDraw = False): self.slices = slices self.numberCalled += 1 self.CommunityColor = QtGui.QColor(colorvalue) if opacity == None: opacity = 0 self.colorvalue = colorvalue if self.Glyph: self.communityMemebership.append(communityMemebership) self.TimeStepRange.append(timesterange) self.ColorQ.append(self.CommunityColor) self.actualValue.append(actualValue) self.opacity = opacity self.AlphaValue.append(opacity) counter= 0 new = [] for value in self.TimeStepRange: new.append(value) self.setToolTip(str(self.AlphaValue)+"\n"+str(self.actualValue) + str(new)+ "\n"+communityMemebership) if len(self.ColorQ) > self.slices: self.AlphaValue = self.AlphaValue[-self.slices:] self.ColorQ = self.ColorQ[-self.slices:] self.actualValue = self.actualValue[-self.slices:] self.TimeStepRange = self.TimeStepRange[-self.slices:] self.communityMemebership = self.communityMemebership[-self.slices:] self.setToolTip(str(self.AlphaValue)+"\n:" + str(self.TimeStepRange)+ "\n") self.NodeCommunityColor = True self.update()
def paint(self, painter, option, widget): """ This method does the drawing. """ painter.setPen(QtCore.Qt.darkGray) painter.setBrush(QtGui.QColor(250, 245, 209)) adjustedRect = self.boundingRect() # the rectangle around the text if self.orientation == 'above': # should draw the label balloon above the point adjustedRect.adjust(0, 0, 0, -12) vertices = [QtCore.QPointF(adjustedRect.width()/2 - 6, adjustedRect.height() - 1), QtCore.QPointF(adjustedRect.width()/2, adjustedRect.height() + 12), QtCore.QPointF(adjustedRect.width()/2 + 6, adjustedRect.height() - 1)] else: # should draw the label balloon below the point adjustedRect.adjust(0, 12, 0, 0) vertices = [QtCore.QPointF(adjustedRect.width()/2 - 6, 1), QtCore.QPointF(adjustedRect.width()/2, -12), QtCore.QPointF(adjustedRect.width()/2 + 6, 1)] # paint the balloon rectangle painter.drawRoundedRect(adjustedRect, 8, 8) # paint the balloon arrow triangle fill painter.setPen(QtCore.Qt.NoPen) painter.drawPolygon(vertices) # paint the balloon arrow triangle stroke painter.setPen(QtCore.Qt.darkGray) painter.drawLine(vertices[0], vertices[1]) painter.drawLine(vertices[2], vertices[1]) # Finally call the parent paint method to draw the actual text super(GraphicsBalloonTextItem, self).paint(painter, option, widget)
def setColor(self, color, emit=True): if isinstance(color, (str, bytes)): self.color = QtGui.QColor(color) else: self.color = color self.update() if emit: self.colorChanged.emit(self.color)