本文整理汇总了Python中PyQt5.QtCore.Qt.red方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.red方法的具体用法?Python Qt.red怎么用?Python Qt.red使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.Qt
的用法示例。
在下文中一共展示了Qt.red方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_highlighted
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import red [as 别名]
def test_highlighted(qtbot):
"""Make sure highlighting works.
Note that with Qt 5.11.3 and > 5.12.1 we need to call setPlainText *after*
creating the highlighter for highlighting to work. Ideally, we'd test
whether CompletionItemDelegate._get_textdoc() works properly, but testing
that is kind of hard, so we just test it in isolation here.
"""
doc = QTextDocument()
completiondelegate._Highlighter(doc, 'Hello', Qt.red)
doc.setPlainText('Hello World')
# Needed so the highlighting actually works.
edit = QTextEdit()
qtbot.addWidget(edit)
edit.setDocument(doc)
colors = [f.foreground().color() for f in doc.allFormats()]
assert QColor('red') in colors
示例2: __init__
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import red [as 别名]
def __init__(self):
QtWidgets.QWidget.__init__(self)
uic.loadUi("window.ui", self)
self.scene = Scene(0, 0, 561, 581)
self.scene.win = self
self.view.setScene(self.scene)
self.image = QImage(561, 581, QImage.Format_ARGB32_Premultiplied)
self.image.fill(Qt.white)
self.bars.clicked.connect(lambda : set_bars(self))
self.erase.clicked.connect(lambda: clean_all(self))
self.paint.clicked.connect(lambda: clipping(self))
self.rect.clicked.connect(lambda: set_rect(self))
self.ect.clicked.connect(lambda: add_bars(self))
self.lines = []
self.clip = None
self.point_now = None
self.input_bars = False
self.input_rect = False
self.pen = QPen(red)
示例3: add_bars
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import red [as 别名]
def add_bars(win):
if len(win.edges) == 0:
QMessageBox.warning(win, "Внимание!", "Не введен отсекатель!")
return
win.pen.setColor(red)
w.lines.append([[win.edges[0].x() - 15, win.edges[0].y() - 15],
[win.edges[1].x() - 15, win.edges[1].y() - 15]])
add_row(w.table_bars)
i = w.table_bars.rowCount() - 1
item_b = QTableWidgetItem("[{0}, {1}]".format(win.edges[0].x() - 15 , win.edges[0].y() - 15))
item_e = QTableWidgetItem("[{0}, {1}]".format(win.edges[1].x() - 15, win.edges[1].y() - 15))
w.table_bars.setItem(i, 0, item_b)
w.table_bars.setItem(i, 1, item_e)
w.scene.addLine(win.edges[0].x() - 15, win.edges[0].y() - 15, win.edges[1].x() - 15, win.edges[1].y() - 15, w.pen)
win.pen.setColor(red)
w.lines.append([[win.edges[0].x() + 15, win.edges[0].y() + 15],
[win.edges[1].x() + 15, win.edges[1].y() + 15]])
add_row(w.table_bars)
i = w.table_bars.rowCount() - 1
item_b = QTableWidgetItem("[{0}, {1}]".format(win.edges[0].x() + 15, win.edges[0].y() + 15))
item_e = QTableWidgetItem("[{0}, {1}]".format(win.edges[1].x() + 15, win.edges[1].y() + 15))
w.table_bars.setItem(i, 0, item_b)
w.table_bars.setItem(i, 1, item_e)
w.scene.addLine(win.edges[0].x() + 15, win.edges[0].y() + 15, win.edges[1].x() + 15, win.edges[1].y() + 15, w.pen)
示例4: clipping
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import red [as 别名]
def clipping(win):
if len(win.clip) <= 1:
QMessageBox.warning(win, "Ошибка!", "Отсекатель не задан!")
if len(win.pol) <= 1:
QMessageBox.warning(win, "Ошибка!", "Многоугольник не задан!")
if len(win.pol) > 1 and len(win.clip) > 1:
norm = isConvex(win.clip)
if not norm:
QMessageBox.warning(win, "Ошибка!", "Отсекатель не выпуклый!Операция не может быть проведена!")
else:
p = sutherland_hodgman(win.clip, win.pol, norm)
if p:
win.pen.setWidth(2)
win.pen.setColor(red)
win.scene.addPolygon(p, win.pen)
win.pen.setWidth(1)
示例5: _updateAutoForegroundColForeground
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import red [as 别名]
def _updateAutoForegroundColForeground(self, row):
item = self.item(row, self._autoForegroundCol)
if item is None: return
try:
value = float(item.data(self._role))
except Exception as ex:
value = 0 # if referenced item doesn't have value or not number, think it as default 0.
if value > 0:
color = Qt.red
elif value < 0:
color = Qt.darkGreen
else:
if item.background() == Qt.white: # for qdarkstyle
color = Qt.black
else:
color = QColor('#C0C0C0')
item.setForeground(color)
示例6: getForegroundOverride
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import red [as 别名]
def getForegroundOverride(self, value):
"""
可由子类重载,这样可以根据不同的值设置不同的前景色
"""
try:
value = float(value)
if value > 0:
color = Qt.red
elif value < 0:
color = Qt.darkGreen
else:
color = None # default
except Exception as ex:
color = None
return color
示例7: data
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import red [as 别名]
def data(self, index, role):
if not index.isValid():
return None
item = index.internalPointer()
if role == Qt.ForegroundRole:
if item.itemData[1] == 'removed':
return QVariant(QColor(Qt.red))
elif item.itemData[1] == 'added':
return QVariant(QColor(Qt.green))
elif item.itemData[1] == 'modified' or item.itemData[1].startswith('['):
return QVariant(QColor(Qt.darkYellow))
if role == Qt.DisplayRole:
return item.data(index.column())
else:
return None
示例8: _drawRect
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import red [as 别名]
def _drawRect(self, qimg):
painter = QPainter()
painter.begin(qimg)
pen = QPen()
pen_width = 3
pen.setWidth(pen_width)
pen.setColor(Qt.red)
painter.setPen(pen)
dw = qimg.width() - pen_width
dh = qimg.height() - pen_width
painter.drawRect(
1,
1,
dw,
dh)
painter.end()
return qimg
示例9: emit
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import red [as 别名]
def emit(self, record):
try:
item = QListWidgetItem(self.format(record))
if record.levelno > logging.INFO:
item.setIcon(QIcon.fromTheme("dialog-warning"))
item.setForeground(QBrush(Qt.red))
else:
item.setIcon(QIcon.fromTheme("dialog-information"))
self.app.exec_in_main(self._add_item, item)
except (KeyboardInterrupt, SystemExit):
raise
except:
self.handleError(record)
示例10: paintEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import red [as 别名]
def paintEvent(self, event):
super(Label, self).paintEvent(event)
# 中正间画十字
painter = QPainter(self)
painter.setPen(Qt.red)
x = int(self.width() / 2)
y = int(self.height() / 2)
painter.drawLine(x, 0, x, self.height())
painter.drawLine(0, y, self.width(), y)
if self.ismd:
# 画坐标点
pos = QCursor.pos()
ret = win32gui.GetPixel(win32gui.GetWindowDC(
win32gui.GetDesktopWindow()), pos.x(), pos.y())
r, g, b = ret & 0xff, (ret >> 8) & 0xff, (ret >> 16) & 0xff
print(r, g, b)
painter.setPen(Qt.white)
painter.drawText(self.rect(), Qt.AlignLeft |
Qt.AlignBottom, '({}, {})\nRGB: ({}, {}, {})\n{}'.format(
pos.x(), pos.y(), r, g, b, QColor(r, g, b).name()))
示例11: test_highlight
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import red [as 别名]
def test_highlight(pat, txt, segments):
doc = QTextDocument(txt)
highlighter = completiondelegate._Highlighter(doc, pat, Qt.red)
highlighter.setFormat = mock.Mock()
highlighter.highlightBlock(txt)
highlighter.setFormat.assert_has_calls([
mock.call(s[0], s[1], mock.ANY) for s in segments
])
示例12: clipping
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import red [as 别名]
def clipping(win):
buf = win.scene.itemAt(now, QTransform()).rect()
win.clip = [buf.left(), buf.right(), buf.top(), buf.bottom()]
for b in win.lines:
pass
win.pen.setColor(blue)
cohen_sutherland(b, win.clip, win)
win.pen.setColor(red)
示例13: add_point
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import red [as 别名]
def add_point(point):
global w
if w.input_rect:
w.pen.setColor(black)
if w.point_now_rect is None:
w.point_now_rect = point
w.point_lock = point
add_row(w.table_rect)
i = w.table_rect.rowCount() - 1
item_x = QTableWidgetItem("{0}".format(point.x()))
item_y = QTableWidgetItem("{0}".format(point.y()))
w.table_rect.setItem(i, 0, item_x)
w.table_rect.setItem(i, 1, item_y)
else:
w.edges.append(point)
w.point_now_rect = point
add_row(w.table_rect)
i = w.table_rect.rowCount() - 1
item_x = QTableWidgetItem("{0}".format(point.x()))
item_y = QTableWidgetItem("{0}".format(point.y()))
w.table_rect.setItem(i, 0, item_x)
w.table_rect.setItem(i, 1, item_y)
item_x = w.table_rect.item(i-1, 0)
item_y = w.table_rect.item(i-1, 1)
w.scene.addLine(point.x(), point.y(), float(item_x.text()), float(item_y.text()), w.pen)
if w.input_bars:
w.pen.setColor(red)
if w.point_now_bars is None:
w.point_now_bars = point
else:
w.lines.append([[w.point_now_bars.x(), w.point_now_bars.y()],
[point.x(), point.y()]])
add_row(w.table_bars)
i = w.table_bars.rowCount() - 1
item_b = QTableWidgetItem("[{0}, {1}]".format(w.point_now_bars.x(), w.point_now_bars.y()))
item_e = QTableWidgetItem("[{0}, {1}]".format(point.x(), point.y()))
w.table_bars.setItem(i, 0, item_b)
w.table_bars.setItem(i, 1, item_e)
w.scene.addLine(w.point_now_bars.x(), w.point_now_bars.y(), point.x(), point.y(), w.pen)
w.point_now_bars = None
示例14: display_title
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import red [as 别名]
def display_title(self):
if len(self.utxos):
if self.read_only:
msg = f'<span>Found 1000 Dash transaction(s):</span>'
else:
msg = f'<span><b>Select the appropriate UTXO then press the <Apply> button or ' \
f'double click on the corresponding row.</b></span>'
self.lblMessage.setText(msg)
self.lblMessage.setVisible(True)
else:
self.lblMessage.setText('<span style="color:red"><b>Found no unspent 1000 Dash transactions in your '
'wallet</b></span>')
self.lblMessage.setVisible(True)
示例15: setHeaderForeground
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import red [as 别名]
def setHeaderForeground(self, color):
"""
只能设置整个header
http://stackoverflow.com/questions/36196988/color-individual-horizontal-headers-of-qtablewidget-in-pyqt
@color: string, like 'red'
"""
self.horizontalHeader().setStyleSheet('color:' + color)