本文整理汇总了Python中PyQt5.QtGui.QBrush方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QBrush方法的具体用法?Python QtGui.QBrush怎么用?Python QtGui.QBrush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui
的用法示例。
在下文中一共展示了QtGui.QBrush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paintEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QBrush [as 别名]
def paintEvent(self, event):
QtWidgets.QFrame.paintEvent(self, event)
painter = QtGui.QPainter()
painter.begin(self)
painter.setRenderHint(QtGui.QPainter.Antialiasing)
painter.setPen(Qt.NoPen)
# Draw the Pie
rwidth = int(min([self.width(), self.height()]) - 2)
x = int((self.width() / 2) - (rwidth / 2))
y = int((self.height() / 2) - (rwidth / 2))
rect = QtCore.QRect(x, y, rwidth, rwidth)
angle1 = 0
for i in range(len(self.data)):
angle2 = angle1 + (3.6 * self.data[i])
painter.setBrush(QtGui.QBrush(self.colors[i % len(self.colors)]))
painter.drawPie(rect, angle1*-16, (angle2-angle1)*-16)
angle1 = angle2
# Draw the remainer (background)
angle2 = 360
painter.setBrush(QtGui.QBrush(self.bgcolor))
painter.drawPie(rect, angle1*-16, (angle2-angle1)*-16)
painter.end()
示例2: __init__
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QBrush [as 别名]
def __init__(self, themes, dataModel, viewMode):
self.width = 0
self.height = 0
self.dataModel = dataModel
self.viewMode = viewMode
self.qpix = self._getNewPixmap(self.width, self.height)
self.backgroundBrush = QtGui.QBrush(themes['background'])
# text font
self.font = themes['font']
# font metrics. assume font is monospaced
self.font.setKerning(False)
self.font.setFixedPitch(True)
fm = QtGui.QFontMetrics(self.font)
self.fontWidth = fm.width('a')
self.fontHeight = fm.height()
self.textPen = QtGui.QPen(QtGui.QColor(192, 192, 192), 0, QtCore.Qt.SolidLine)
示例3: updateDetailScreen
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QBrush [as 别名]
def updateDetailScreen(self):
self.textBrowser.clear()
self.currentTreeWidget = self.treeWidget.currentItem()
try:
scriptName = self.currentTreeWidget.text(0)
scriptNo = scriptName.replace("script", "")
indexSelectedScript = videoscriptcore.getScripts().index(int(scriptNo))
selectedScript = videoscriptcore.video_scripts[indexSelectedScript]
self.currentScriptSelected = selectedScript.scriptno
self.textBrowser.append("Category: %s\n"%selectedScript.sub_reddit)
self.textBrowser.append("Upvotes: %s"%selectedScript.upvotes)
self.textBrowser.append("Author: %s"%selectedScript.author)
self.textBrowser.append("Vid Number: %s"%selectedScript.vidNo)
self.textBrowser.append("Status: %s"%selectedScript.status)
self.textBrowser.append("Script ID: %s"%selectedScript.scriptno)
self.textBrowser.append("Being Edited by: %s"%selectedScript.editedby)
self.textBrowser.append("\nTitle: %s\n"%selectedScript.title)
self.editedby.setText(selectedScript.editedby)
self.currentTreeWidget.setForeground(0, QtGui.QBrush(QtGui.QColor("blue")))
except AttributeError:
pass
self.updateColors()
开发者ID:HA6Bots,项目名称:Automatic-Youtube-Reddit-Text-To-Speech-Video-Generator-and-Uploader,代码行数:25,代码来源:rawscriptsmenu.py
示例4: updateColors
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QBrush [as 别名]
def updateColors(self):
try:
children = self.count_tems()
for i in range(len(children)):
scriptName = children[i].text(0)
scriptNo = scriptName.replace("script", "")
indexSelectedScript = videoscriptcore.getScripts().index(int(scriptNo))
status = videoscriptcore.video_scripts[indexSelectedScript].status
if hasattr(self, "currentTreeWidget"):
if status == "RAW":
if settings.darkMode:
children[i].setForeground(0, QtGui.QBrush(QtGui.QColor("white")))
else:
children[i].setForeground(0, QtGui.QBrush(QtGui.QColor("black")))
elif status == "EDITING":
children[i].setForeground(0, QtGui.QBrush(QtGui.QColor("yellow")))
elif status == "COMPLETE":
children[i].setForeground(0, QtGui.QBrush(QtGui.QColor("green")))
elif status == "MANUALCOMPLETE":
children[i].setForeground(0, QtGui.QBrush(QtGui.QColor("darkgreen")))
elif status == "QUALITY":
children[i].setForeground(0, QtGui.QBrush(QtGui.QColor("red")))
except:
print("error occured recolouring scripts")
开发者ID:HA6Bots,项目名称:Automatic-Youtube-Reddit-Text-To-Speech-Video-Generator-and-Uploader,代码行数:26,代码来源:rawscriptsmenu.py
示例5: addRawScriptsToTree
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QBrush [as 别名]
def addRawScriptsToTree(self):
self.treeWidget.clear()
for i, vid in enumerate(videoscriptcore.video_scripts):
new_item = self.addChild(vid.sub_reddit, "script%s"%vid.vidNo)
if vid.status == "EDITING":
new_item.setForeground(0, QtGui.QBrush(QtGui.QColor("yellow")))
elif vid.status == "RAW":
if settings.darkMode:
new_item.setForeground(0, QtGui.QBrush(QtGui.QColor("white")))
else:
new_item.setForeground(0, QtGui.QBrush(QtGui.QColor("black")))
elif vid.status == "COMPLETE":
new_item.setForeground(0, QtGui.QBrush(QtGui.QColor("green")))
elif vid.status == "MANUALCOMPLETE":
new_item.setForeground(0, QtGui.QBrush(QtGui.QColor("darkgreen")))
self.treeWidget.expandToDepth(0)
开发者ID:HA6Bots,项目名称:Automatic-Youtube-Reddit-Text-To-Speech-Video-Generator-and-Uploader,代码行数:19,代码来源:rawscriptsmenu.py
示例6: paintEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QBrush [as 别名]
def paintEvent(self, event):
painter = QPainter()
painter.begin(self)
painter.setRenderHint(QPainter.Antialiasing)
painter.fillRect(event.rect(), QBrush(QColor(255, 255, 255, 200)))
painter.setPen(QPen(Qt.NoPen))
if self.lists is not None:
path = os.path.abspath(os.path.dirname(__file__)) + '/static/'
path += self.lists[self.list_index] + '.png'
self.list_index += 1
if self.list_index >= len(self.lists):
self.list_index = 0
image = QImage(path)
rect_image = image.rect()
rect_painter = event.rect()
dx = (rect_painter.width() - rect_image.width()) / 2.0
dy = (rect_painter.height() - rect_image.height()) / 2.0
painter.drawImage(dx, dy, image)
painter.end()
示例7: highligting
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QBrush [as 别名]
def highligting(self, color, underline_width):
color = QColor(color)
color = QColor(color.red(), color.green(), color.blue(), 200)
painter = QPainter(self)
if config.hover_underline:
font_metrics = QFontMetrics(self.font())
text_width = font_metrics.width(self.word)
text_height = font_metrics.height()
brush = QBrush(color)
pen = QPen(brush, underline_width, Qt.SolidLine, Qt.RoundCap)
painter.setPen(pen)
if not self.skip:
painter.drawLine(0, text_height - underline_width, text_width, text_height - underline_width)
if config.hover_hightlight:
x = y = 0
y += self.fontMetrics().ascent()
painter.setPen(color)
painter.drawText(x, y + config.outline_top_padding - config.outline_bottom_padding, self.word)
示例8: set_colors
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QBrush [as 别名]
def set_colors(self, changed='66d9ef', unchanged='d2d2d2', default='ffffff', select='a9c5ff'):
'''Sets the colors associated with the various properties.
Args:
changed (:obj:`str`): Change color, default: '66d9ef'
unchanged (:obj:`str`): Unchanged color, default: 'd2d2d2'
default (:obj:`str`): Default color, default: 'ffffff'
select (:obj:`str`): Selected color, default: 'a9c5ff'
'''
colors = [changed, unchanged, default, select]
if None in [re.match('^[a-fA-F0-9]{6}$', x) for x in colors]:
# Invalid color provided
return
self.colors = []
for c in colors:
r, g, b = int(c[:2], 16), int(c[2:4], 16), int(c[-2:], 16)
self.colors.append(QtGui.QBrush(QtGui.QColor.fromRgb(r, g, b)))
示例9: drawSelected
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QBrush [as 别名]
def drawSelected(self, qp):
qp.setFont(self.font)
cursorX, cursorY = self.cursor.getPosition()
if len(self.OPCODES) - 1 < cursorY:
return
asm = self.OPCODES[cursorY]
cx, width, text = asm.getSelectedToken(cursorX)
cemu = ConsoleEmulator(qp, self.ROWS, self.COLUMNS)
for i, asm in enumerate(self.OPCODES):
for idx, length, value in asm.tokens():
# skip current cursor position
if cursorY == i and cursorX == idx:
continue
# check every line, if match, select it
if value == text:
qp.setOpacity(0.4)
brush=QtGui.QBrush(QtGui.QColor(0, 255, 0))
qp.fillRect(idx*self.fontWidth, i*self.fontHeight + 2 , width*self.fontWidth, self.fontHeight, brush)
qp.setOpacity(1)
示例10: __init__
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QBrush [as 别名]
def __init__(self, dataModel, viewMode):
self.width = 0
self.height = 0
self.dataModel = dataModel
self.viewMode = viewMode
self.qpix = self._getNewPixmap(self.width, self.height)
self.backgroundBrush = QtGui.QBrush(QtGui.QColor(0, 0, 128))
# text font
self.font = QtGui.QFont('Terminus', 11, QtGui.QFont.Light)
# font metrics. assume font is monospaced
self.font.setKerning(False)
self.font.setFixedPitch(True)
fm = QtGui.QFontMetrics(self.font)
self.fontWidth = fm.width('a')
self.fontHeight = fm.height()
self.textPen = QtGui.QPen(QtGui.QColor(192, 192, 192), 0, QtCore.Qt.SolidLine)
示例11: __init__
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QBrush [as 别名]
def __init__(self, dataModel, viewMode, elfplugin):
self.width = 0
self.height = 0
self.dataModel = dataModel
self.viewMode = viewMode
self.qpix = self._getNewPixmap(self.width, self.height)
self.backgroundBrush = QtGui.QBrush(QtGui.QColor(0, 0, 128))
self.elfplugin = elfplugin
self.elf = self.elfplugin.elf
# text font
self.font = QtGui.QFont('Terminus', 11, QtGui.QFont.Bold)
# font metrics. assume font is monospaced
self.font.setKerning(False)
self.font.setFixedPitch(True)
fm = QtGui.QFontMetrics(self.font)
self.fontWidth = fm.width('a')
self.fontHeight = fm.height()
self.textPen = QtGui.QPen(QtGui.QColor(192, 192, 192), 0, QtCore.Qt.SolidLine)
示例12: init
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QBrush [as 别名]
def init(self, viewMode, parent):
self.viewMode = viewMode
self.MZbrush = QtGui.QBrush(QtGui.QColor(128, 0, 0))
self.greenPen = QtGui.QPen(QtGui.QColor(255, 255, 0))
self.textDecorator = TextDecorator(viewMode)
self.textDecorator = HighlightASCII(self.textDecorator)
self.textDecorator = HighlightPrefix(self.textDecorator, '\x55\xAA', brush=self.MZbrush, pen=self.greenPen)
self.viewMode.setTransformationEngine(self.textDecorator)
self.viewMode.selector.addSelection((446, 446+1*16, QtGui.QBrush(QtGui.QColor(125, 75, 150)), 0.8), type=TextSelection.SelectionType.PERMANENT)
self.viewMode.selector.addSelection((446+16, 446+2*16, QtGui.QBrush(QtGui.QColor(55, 125, 50)), 0.8), type=TextSelection.SelectionType.PERMANENT)
self.viewMode.selector.addSelection((446+2*16, 446+3*16, QtGui.QBrush(QtGui.QColor(125, 75, 150)), 0.8), type=TextSelection.SelectionType.PERMANENT)
self.viewMode.selector.addSelection((446+3*16, 446+4*16, QtGui.QBrush(QtGui.QColor(55, 125, 50)), 0.8), type=TextSelection.SelectionType.PERMANENT)
return True
示例13: init
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QBrush [as 别名]
def init(self, viewMode, parent):
self._viewMode = viewMode
self.MZbrush = QtGui.QBrush(QtGui.QColor(128, 0, 0))
self.greenPen = QtGui.QPen(QtGui.QColor(255, 255, 0))
self.grayBrush = QtGui.QBrush(QtGui.QColor(128, 128, 128))
self.whitePen = QtGui.QPen(QtGui.QColor(255, 255, 255))
self.textDecorator = TextDecorator(viewMode)
self.textDecorator = HighlightASCII(self.textDecorator)
self.textDecorator = HighlightPrefix(self.textDecorator, 'MZ', brush=self.MZbrush, pen=self.greenPen)
self.textDecorator = HighlightPrefix(self.textDecorator, 'PE\x00\x00', brush=self.MZbrush, pen=self.greenPen)
self.textDecorator = HighlightPrefix(self.textDecorator, '\xFF\x15', additionalLength=4, brush=self.grayBrush, pen=self.whitePen)
self.textDecorator = HighlightWideChar(self.textDecorator)
self._viewMode.setTransformationEngine(self.textDecorator)
return True
示例14: generic_shape_mouseReleaseEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QBrush [as 别名]
def generic_shape_mouseReleaseEvent(self, e):
if self.last_pos:
# Clear up indicator.
self.timer_cleanup()
p = QPainter(self.pixmap())
p.setPen(QPen(self.primary_color, self.config['size'], Qt.SolidLine, Qt.SquareCap, Qt.MiterJoin))
if self.config['fill']:
p.setBrush(QBrush(self.secondary_color))
getattr(p, self.active_shape_fn)(QRect(self.origin_pos, e.pos()), *self.active_shape_args)
self.update()
self.reset_mode()
# Line events
示例15: __init__
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QBrush [as 别名]
def __init__(self, column, row):
super().__init__()
self.scene = QtWidgets.QGraphicsScene()
self.setScene(self.scene)
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
# TODO see EditorMap redraw
brushes = {0: QtGui.QBrush(QtGui.QColor(64, 64, 255)), 1: QtGui.QBrush(QtGui.QColor(64, 255, 64)),
2: QtGui.QBrush(QtGui.QColor(64, 255, 64)), 3: QtGui.QBrush(QtGui.QColor(64, 255, 64)),
4: QtGui.QBrush(QtGui.QColor(222, 222, 222)), 5: QtGui.QBrush(QtGui.QColor(0, 128, 0)),
6: QtGui.QBrush(QtGui.QColor(222, 222, 0))}
# TODO hardcore tile size somewhere else (and a bit less hard)
self.TILE_SIZE = 80
for i in range(0, 6):
y = i // 4
x = i % 4
self.scene.addRect(x * self.TILE_SIZE, y * self.TILE_SIZE, self.TILE_SIZE, self.TILE_SIZE,
brush=brushes[i], pen=qt.TRANSPARENT_PEN)