本文整理汇总了Python中PyQt4.QtGui.QColor方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QColor方法的具体用法?Python QtGui.QColor怎么用?Python QtGui.QColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui
的用法示例。
在下文中一共展示了QtGui.QColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawPoint
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QColor [as 别名]
def drawPoint(self, qp, pt, isFirst, increaseRadius):
# The first in green
if isFirst:
qp.setBrush(QtGui.QBrush(QtGui.QColor(0,255,0),QtCore.Qt.SolidPattern))
# Other in red
else:
qp.setBrush(QtGui.QBrush(QtGui.QColor(255,0,0),QtCore.Qt.SolidPattern))
# Standard radius
r = 3.0
# Increase maybe
if increaseRadius:
r *= 2.5
# Draw
qp.drawEllipse( pt, r, r )
# Determine if the given candidate for a label path makes sense
示例2: drawHZ
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QColor [as 别名]
def drawHZ(self,qp):
qp.resetTransform()
w = self.width()
h = self.height()
defaultCol = QColor(0,255,0, 200)
top = 50
bottom = h-50
width, height = w*0.2, 22
dist = 10
space = height+dist
pos = width/4
for i,k in enumerate(self.hzDisplay.hz.keys()):
t = self.hzDisplay.hz[k][1]
v = self.hzDisplay.hz[k][0]
if t<0:
self.drawBar(qp, QRectF(pos, top+space*(6+i), width,height), QColor(128,128,128,200), k+' OFF', 0, 0, 1)
else:
self.drawBar(qp, QRectF(pos, top+space*(6+i), width,height), defaultCol, k+': %5.1fhz'%v, v, 0, t)
示例3: setTheme
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QColor [as 别名]
def setTheme(self):
# the application window only has a vertical container which contains
# exactly 3 items: a header image, a spacer for the active screen, and a footer
self.container = VerticalContainer(self)
self.container.setGeometry(0, 0, APP_WIDTH, APP_HEIGHT)
# changing the background color of the main window
palette = self.palette()
palette.setColor(self.backgroundRole(), QtGui.QColor(255, 132, 42)) # FF842A
self.setPalette(palette)
# adding the 3 items to the application container
self.container.addImage(os.path.join(images_path, 'header.png'))
self.container.addSpacer(CONTAINER_HEIGHT)
footer = self.container.addLabel("Questions? Visit help.kano.me", objectName=LABEL_CSS_FOOTER)
load_css_for_widget(footer, os.path.join(css_path, 'label.css'))
示例4: pushButtonAutoCheckClicked
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QColor [as 别名]
def pushButtonAutoCheckClicked(self):
root = self.treeWidget.invisibleRootItem()
success = 0
fail = 0
for i in range(root.childCount()):
item = root.child(i)
exploit = self.__exploits[str(item.text(0))]
if exploit.check():
exploit.vulnerable = True
w = self.__stackedWidgetController.getWidgetWithExploit(exploit)
w.setCheckBoxVulnerableChecked(True)
self.addExploitSuccess(exploit)
success += 1
item.setForeground(0, QBrush(QColor(Qt.green)))
else:
fail += 1
item.setForeground(0, QBrush(QColor(Qt.red)))
self.labelCheck.setText("Result: {0} OK - {1} Fail".format(success, fail))
示例5: __init__
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QColor [as 别名]
def __init__(self, qwtPlot, scale=None, hasGrid=True):
self.__plot__ = qwtPlot
if hasGrid:
self.__curveCpuPlotGrid= Qwt.QwtPlotGrid()
self.__curveCpuPlotGrid.setMajPen(QtGui.QPen(QtGui.QColor(0,100,0), 0, QtCore.Qt.SolidLine))
self.__curveCpuPlotGrid.setMinPen(QtGui.QPen(QtGui.QColor(0,100,0), 0, QtCore.Qt.SolidLine))
self.__curveCpuPlotGrid.enableXMin(True)
self.__curveCpuPlotGrid.attach(self.__plot__)
self.__plot__.setCanvasBackground(QtGui.QColor(0,0,0))
self.__plot__.enableAxis(0, False )
self.__plot__.enableAxis(2, False )
if scale is None:
#self.__plot__.setAxisScale(0,0,100,20)
pass
else:
self.__plot__.setAxisScale(0, scale.min, scale.max, (scale.max - scale.min) / 10.0)
示例6: __init__
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QColor [as 别名]
def __init__(self, plot, depth, reader, card, scale):
self.__curveNetInHist__ = plotobjects.niceCurve("Network In History",
1 ,QtGui.QColor(241,254,1), QtGui.QColor(181,190,1),
plot)
self.__curveNetOutHist__ = plotobjects.niceCurve("Network Out History",
1, QtGui.QColor(28,255,255),QtGui.QColor(0,168,168),
plot)
self.__depth__ = depth
self.__reader__ = reader
self.__first__ = False
self.__plot__ = plot
self.__card__ = card
#adapt the network plot
self.__adaptednetworkplot = plotobjects.procExpPlot(self.__plot__, scale)
self.__networkInUsageHistory__ = [0] * int(self.__depth__)
self.__networkOutUsageHistory__ = [0] * int(self.__depth__)
示例7: __init__
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QColor [as 别名]
def __init__(self, parent):
super(PageMarker, self).__init__(parent)
self.height = 10
self.bg_color = QtGui.QColor(255, 255, 255, 50)
self.fg_color = QtGui.QColor(255, 255, 255, 70)
self.screenRect = QtGui.QApplication.desktop().screen().rect()
self.setAutoFillBackground(True)
p = self.palette()
p.setColor(self.backgroundRole(), self.bg_color)
self.setPalette(p)
# make full width, and move to bottom of screen
self.setFixedWidth(self.screenRect.width())
self.setFixedHeight(self.height)
self.move(0, self.screenRect.height() - self.height)
self.set(1, 0)
示例8: mouseMoveEvent
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QColor [as 别名]
def mouseMoveEvent(self, e):
if e.buttons() == QtCore.Qt.LeftButton:
mimeData = QtCore.QMimeData()
mimeData.setText('%d,%d' % (e.x(), e.y()))
# show the ghost image while dragging
pixmap = QtGui.QPixmap.grabWidget(self)
painter = QtGui.QPainter(pixmap)
painter.fillRect(pixmap.rect(), QtGui.QColor(0, 0, 0, 127))
painter.end()
drag = QtGui.QDrag(self)
drag.setMimeData(mimeData)
drag.setPixmap(pixmap)
drag.setHotSpot(e.pos())
drag.exec_(QtCore.Qt.MoveAction)
示例9: test_takes_with_representations_shows_in_blue
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QColor [as 别名]
def test_takes_with_representations_shows_in_blue(self):
"""testing if takes with representations will be displayed in blue
"""
# select project 1 -> task1
item_model = self.dialog.tasks_treeView.model()
selection_model = self.dialog.tasks_treeView.selectionModel()
index = item_model.index(0, 0)
project1_item = item_model.itemFromIndex(index)
self.dialog.tasks_treeView.expand(index)
task1_item = project1_item.child(0, 0)
selection_model.select(
task1_item.index(),
QtGui.QItemSelectionModel.Select
)
# expect only one "Main" take listed in take_listWidget
main_item = self.dialog.takes_listWidget.item(0)
item_foreground = main_item.foreground()
color = item_foreground.color()
self.assertEqual(
color,
QtGui.QColor(0, 0, 255)
)
示例10: init
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QColor [as 别名]
def init(self, history=512, autoscale=True):
self.widget = pg.PlotWidget()
self.widget.block = self
self.gr_block.set_history(history)
self.plot = self.widget.plot()
self.plot.setPen(QtGui.QColor(self.input.color))
#self.widget.setYRange(*self.yrange)
self.widget.enableAutoRange('y', 0.95 if autoscale else False)
self.buffer = []
self.timer = QtCore.QTimer()
self.timer.timeout.connect(self.updateGUI)
self.timer.start(100)
示例11: set_feature_vertex_marker
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QColor [as 别名]
def set_feature_vertex_marker(map_canvas, lon, lat, color=VERTEX_COLOR):
"""
Sets single feature vertex
:param map_canvas: Map canvas object
:param lat: Vertex latitude value
:param lon: Vertex longitude value
:param color: Vertex color
:return marker: Vertex object
:rtype marker: Object
"""
marker = q_gui.QgsVertexMarker(map_canvas)
marker.setCenter(q_core.QgsPoint(lon, lat))
marker.setColor(qg.QColor(color))
marker.setIconType(q_gui.QgsVertexMarker.ICON_CIRCLE)
marker.setPenWidth(4)
return marker
示例12: get_colour
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QColor [as 别名]
def get_colour(self):
if self.type == CorrectionBox.types.TO_CORRECT:
return QtGui.QColor(255,0,0)
elif self.type == CorrectionBox.types.TO_REVIEW:
return QtGui.QColor(255,255,0)
elif self.type == CorrectionBox.types.RESOLVED:
return QtGui.QColor(0,255,0)
elif self.type == CorrectionBox.types.QUESTION:
return QtGui.QColor(0,0,255)
示例13: _initEditor
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QColor [as 别名]
def _initEditor(self):
self.ui.sqlEditor = QsciScintilla(self)
self.ui.sqlEditor.textChanged.connect(self.setValidQuery)
# Don't want to see the horizontal scrollbar at all
self.ui.sqlEditor.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)
self.ui.sqlEditor.setMarginLineNumbers(0, True)
self.ui.sqlEditor.setMarginWidth(0, "000")
self.ui.sqlEditor.setMarginsForegroundColor(QColor("#2468A7"))
# Brace matching: enable for a brace immediately before or after
# the current position.
self.ui.sqlEditor.setBraceMatching(QsciScintilla.SloppyBraceMatch)
# Current line visible with special background color
self.ui.sqlEditor.setCaretLineVisible(True)
self.ui.sqlEditor.setCaretLineBackgroundColor(QColor("#E4EEFF"))
lexer = QsciLexerSQL()
self.ui.sqlEditor.setLexer(lexer)
''' TODO autocomplete.
api = QsciAPIs(lexer)
api.add('aLongString')
api.add('aLongerString')
api.add('aDifferentString')
api.add('sOmethingElse')
api.prepare()
self.ui.sqlEditor.setAutoCompletionThreshold(1)
self.ui.sqlEditor.setAutoCompletionSource(QsciScintilla.AcsAPIs)
'''
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.ui.sqlEditor.sizePolicy().hasHeightForWidth())
self.ui.sqlEditor.setSizePolicy(sizePolicy)
self.ui.splitter.setSizes([self.size().width() * 0.6, self.size().height() * 0.4])
self.ui.leftContainer.insertWidget(1, self.ui.sqlEditor)
示例14: set_resource_info
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QColor [as 别名]
def set_resource_info(self, resource_info):
resource_name, resource_type, is_loaded = resource_info
items = self.resourceListWidget.findItems(resource_name, QtCore.Qt.MatchExactly, column=0)
for item in items:
if item.text(1) == resource_type:
break
else:
item = QtGui.QTreeWidgetItem(self.resourceListWidget)
item.is_loaded = is_loaded
fontColor = 'black' if is_loaded else 'gray'
item.setTextColor(0, QtGui.QColor(fontColor))
item.setTextColor(1, QtGui.QColor(fontColor))
item.setText(0, resource_name)
item.setText(1, resource_type)
示例15: drawBar
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QColor [as 别名]
def drawBar(self, qp, rect, col, txt, val, minVal=0, maxVal=100):
valN = (float(val)-minVal)/(maxVal-minVal)*100.
percent = min(max(valN,0),100)
#qp = QtGui.QPainter()
qp.setBrush(QColor(0,0,0,0))
qp.setPen(col)
qp.drawRect(rect)
qp.setBrush(col.light())
qp.drawText(rect, Qt.AlignCenter, txt)
qp.setBrush(col.dark())
qp.drawRect(QRectF(rect.left(), rect.top(), rect.width()/100.*percent, rect.height()))