本文整理汇总了Python中PyQt5.QtCore.Qt.green方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.green方法的具体用法?Python Qt.green怎么用?Python Qt.green使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.Qt
的用法示例。
在下文中一共展示了Qt.green方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: data
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import green [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
示例2: draw
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import green [as 别名]
def draw(self, defending, status, scene, size):
"""function draw
:param defending: bool
:param status: str {'Charge', 'Shoot', 'Stand'}
:param scene: QGraphicsScene
:param size: QSize
no return
"""
if not isinstance(defending, bool):
raise ValueError('defending must be a boolean')
if not isinstance(status, str) or (status != 'Charge' and status != 'Shoot' and status != 'Stand'):
raise ValueError('status must be a str in {\'Charge\', \'Shoot\', \'Stand\'}')
self.unitType.draw(defending, status, scene, size)
flag_width = self.nation.flag.width() * 10 / self.nation.flag.height()
item = scene.addPixmap(self.nation.flag.scaled(flag_width, 10))
item.setPos(size.width() - 5 - flag_width, 0)
# life bar
item1 = QGraphicsRectItem(0, size.height() - 10, size.width() - 5, 5)
item1.setBrush(QBrush(Qt.white))
item2 = QGraphicsRectItem(0, size.height() - 10, self.unitStrength / 100 * (size.width() - 5), 5)
item2.setBrush(QBrush(Qt.green))
# moral bar
item3 = QGraphicsRectItem(0, size.height() - 15, size.width() - 5, 5)
item3.setBrush(QBrush(Qt.white))
item4 = QGraphicsRectItem(0, size.height() - 15, self.moral / 100 * (size.width() - 5), 5)
item4.setBrush(QBrush(Qt.blue))
scene.addItem(item1)
scene.addItem(item2)
scene.addItem(item3)
scene.addItem(item4)
示例3: setBlackoutColors
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import green [as 别名]
def setBlackoutColors(self):
global colors
global orange
colors = [Qt.red, Qt.yellow, Qt.darkYellow, Qt.green, Qt.darkGreen, orange, Qt.blue,Qt.cyan, Qt.darkCyan, Qt.magenta, Qt.darkMagenta, Qt.gray]
# return
# self.setStyleSheet("background-color: black")
#self.Plot24.setBackgroundBrush(Qt.black)
mainTitleBrush = QBrush(Qt.red)
self.chart24.setTitleBrush(mainTitleBrush)
self.chart5.setTitleBrush(mainTitleBrush)
self.chart24.setBackgroundBrush(QBrush(Qt.black))
self.chart24.axisX().setLabelsColor(Qt.white)
self.chart24.axisY().setLabelsColor(Qt.white)
titleBrush = QBrush(Qt.white)
self.chart24.axisX().setTitleBrush(titleBrush)
self.chart24.axisY().setTitleBrush(titleBrush)
#self.Plot5.setBackgroundBrush(Qt.black)
self.chart5.setBackgroundBrush(QBrush(Qt.black))
self.chart5.axisX().setLabelsColor(Qt.white)
self.chart5.axisY().setLabelsColor(Qt.white)
self.chart5.axisX().setTitleBrush(titleBrush)
self.chart5.axisY().setTitleBrush(titleBrush)
#$ self.networkTable.setStyleSheet("QTableCornerButton::section{background-color: white;}")
# self.networkTable.cornerWidget().setStylesheet("background-color: black")
self.networkTable.setStyleSheet("QTableView {background-color: black;gridline-color: white;color: white} QTableCornerButton::section{background-color: white;}")
headerStyle = "QHeaderView::section{background-color: white;border: 1px solid black;color: black;} QHeaderView::down-arrow,QHeaderView::up-arrow {background: none;}"
self.networkTable.horizontalHeader().setStyleSheet(headerStyle)
self.networkTable.verticalHeader().setStyleSheet(headerStyle)
示例4: draw_apple
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import green [as 别名]
def draw_apple(self, painter: QtGui.QPainter) -> None:
apple_location = self.snake.apple_location
if apple_location:
painter.setRenderHints(QtGui.QPainter.HighQualityAntialiasing)
painter.setPen(QtGui.QPen(Qt.black))
painter.setBrush(QtGui.QBrush(Qt.green))
painter.drawRect(apple_location.x * SQUARE_SIZE[0],
apple_location.y * SQUARE_SIZE[1],
SQUARE_SIZE[0],
SQUARE_SIZE[1])
示例5: __init__
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import green [as 别名]
def __init__(self, ui):
super().__init__(ui)
self.food_coordinates = None
self.wlabC = {
WLAB['U']: Qt.white,
WLAB['WORM']: Qt.green,
WLAB['WORMS']: Qt.blue,
WLAB['BAD']: Qt.darkRed,
WLAB['GOOD_SKE']: Qt.darkCyan
}
self.ui.checkBox_showFood.stateChanged.connect(self.updateImage)
self.ui.checkBox_showFood.setEnabled(False)
self.ui.checkBox_showFood.setChecked(True)
示例6: onCurrentRowChanged
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import green [as 别名]
def onCurrentRowChanged(self, currentRow):
self.resultView.appendHtml(
'{0}: {1}'.format(
formatColor('currentRowChanged', QColor(Qt.green)),
currentRow))
示例7: __init__
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import green [as 别名]
def __init__(self, *args, **kwargs):
super(CalendarWidget, self).__init__(*args, **kwargs)
# 隐藏左边的序号
self.setVerticalHeaderFormat(self.NoVerticalHeader)
# 修改周六周日颜色
fmtGreen = QTextCharFormat()
fmtGreen.setForeground(QBrush(Qt.green))
self.setWeekdayTextFormat(Qt.Saturday, fmtGreen)
fmtOrange = QTextCharFormat()
fmtOrange.setForeground(QBrush(QColor(252, 140, 28)))
self.setWeekdayTextFormat(Qt.Sunday, fmtOrange)
示例8: on_get_annotations
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import green [as 别名]
def on_get_annotations(self, address, size, mouse_offs):
ann = []
ip = get_ip_val()
sp = get_sp_val()
if ip is not None and sp is not None:
ann.append((ip, Qt.red, "%X (IP)" % ip, Qt.red))
ann.append((sp, Qt.green, "%X (SP)" % sp, Qt.green))
return ann
示例9: onGPSStatus
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import green [as 别名]
def onGPSStatus(self, updateStatusBar=True):
if (not self.remoteAgentUp):
# Checking local GPS
if GPSEngine.GPSDRunning():
if self.gpsEngine.gpsValid():
self.gpsSynchronized = True
self.btnGPSStatus.setStyleSheet("background-color: green; border: 1px;")
if updateStatusBar:
self.statusBar().showMessage('Local gpsd service is running and satellites are synchronized.')
else:
self.gpsSynchronized = False
self.btnGPSStatus.setStyleSheet("background-color: yellow; border: 1px;")
if updateStatusBar:
self.statusBar().showMessage("Local gpsd service is running but it's not synchronized with the satellites yet.")
else:
self.gpsSynchronized = False
if updateStatusBar:
self.statusBar().showMessage('No local gpsd running.')
self.btnGPSStatus.setStyleSheet("background-color: red; border: 1px;")
else:
# Checking remote
errCode, errMsg, gpsStatus = requestRemoteGPS(self.remoteAgentIP, self.remoteAgentPort)
if errCode == 0:
self.missedAgentCycles = 0
if (gpsStatus.isValid):
self.gpsSynchronized = True
self.btnGPSStatus.setStyleSheet("background-color: green; border: 1px;")
self.statusBar().showMessage("Remote GPS is running and synchronized.")
elif (gpsStatus.gpsRunning):
self.gpsSynchronized = False
self.btnGPSStatus.setStyleSheet("background-color: yellow; border: 1px;")
self.statusBar().showMessage("Remote GPS is running but it has not synchronized with the satellites yet.")
else:
self.gpsSynchronized = False
self.statusBar().showMessage("Remote GPS service is not running.")
self.btnGPSStatus.setStyleSheet("background-color: red; border: 1px;")
else:
agentUp = portOpen(self.remoteAgentIP, self.remoteAgentPort)
# Agent may be up but just taking a while to respond.
if (not agentUp) or errCode == -1:
self.missedAgentCycles += 1
if (not agentUp) or (self.missedAgentCycles > self.allowedMissedAgentCycles):
# We may let it miss a cycle or two just as a good practice
# Agent disconnected.
# Stop any active scan and transition local
self.agentDisconnected()
self.statusBar().showMessage("Error connecting to remote agent. Agent disconnected.")
QMessageBox.question(self, 'Error',"Error connecting to remote agent. Agent disconnected.", QMessageBox.Ok)
else:
self.statusBar().showMessage("Remote GPS Error: " + errMsg)
self.btnGPSStatus.setStyleSheet("background-color: red; border: 1px;")
示例10: __init__
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import green [as 别名]
def __init__(self, *args, **kwargs):
super(ButtonsWidget, self).__init__(*args, **kwargs)
layout = QGridLayout(self)
loader = CIconLoader.fontMaterial()
# 创建一个多态的icon
icon = loader.icon('mdi-qqchat')
icon.add('mdi-access-point', Qt.red, QIcon.Normal, QIcon.On)
icon.add('mdi-camera-metering-matrix',
Qt.green, QIcon.Disabled, QIcon.Off)
icon.add('mdi-file-document-box-check',
Qt.blue, QIcon.Disabled, QIcon.On)
icon.add('mdi-magnify-minus', Qt.cyan, QIcon.Active, QIcon.Off)
icon.add('mdi-account', Qt.magenta, QIcon.Active, QIcon.On)
icon.add('mdi-camera-off', Qt.yellow, QIcon.Selected, QIcon.Off)
icon.add('mdi-set-center', Qt.white, QIcon.Selected, QIcon.On)
layout.addWidget(QLabel('Normal', self), 0, 0)
layout.addWidget(QPushButton(self, icon=icon, text=loader.value(
'mdi-qqchat'), font=loader.font, iconSize=QSize(36, 36)), 0, 1)
layout.addWidget(QLabel('Disabled', self), 1, 0)
layout.addWidget(QPushButton(self, icon=icon, text=loader.value(
'mdi-qqchat'), enabled=False, font=loader.font, iconSize=QSize(48, 48)), 1, 1)
layout.addWidget(QLabel('Active', self), 2, 0)
layout.addWidget(QPushButton(self, icon=icon, text=loader.value(
'mdi-qqchat'), font=loader.font, iconSize=QSize(64, 64)), 2, 1)
layout.addWidget(QLabel('Selected', self), 3, 0)
layout.addWidget(QPushButton(self, icon=icon, text=loader.value(
'mdi-qqchat'), font=loader.font, checkable=True, checked=True), 3, 1)
# 旋转动画
aniButton = QPushButton(self, iconSize=QSize(48, 48))
loader = CIconLoader.fontAwesome()
icon = loader.icon(
'fa-spinner', animation=CIconAnimationSpin(aniButton, 10, 4))
aniButton.setIcon(icon)
layout.addWidget(QLabel('动画', self), 4, 0)
layout.addWidget(aniButton, 4, 1)
示例11: draw_snake
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import green [as 别名]
def draw_snake(self, painter: QtGui.QPainter) -> None:
painter.setRenderHints(QtGui.QPainter.HighQualityAntialiasing)
pen = QtGui.QPen()
pen.setColor(QtGui.QColor(0, 0, 0))
# painter.setPen(QtGui.QPen(Qt.black))
painter.setPen(pen)
brush = QtGui.QBrush()
brush.setColor(Qt.red)
painter.setBrush(QtGui.QBrush(QtGui.QColor(198, 5, 20)))
# painter.setBrush(brush)
def _draw_line_to_apple(painter: QtGui.QPainter, start_x: int, start_y: int, drawable_vision: DrawableVision) -> Tuple[int, int]:
painter.setPen(QtGui.QPen(Qt.green))
end_x = drawable_vision.apple_location.x * SQUARE_SIZE[0] + SQUARE_SIZE[0]/2
end_y = drawable_vision.apple_location.y * SQUARE_SIZE[1] + SQUARE_SIZE[1]/2
painter.drawLine(start_x, start_y, end_x, end_y)
return end_x, end_y
def _draw_line_to_self(painter: QtGui.QPainter, start_x: int, start_y: int, drawable_vision: DrawableVision) -> Tuple[int, int]:
painter.setPen(QtGui.QPen(Qt.red))
end_x = drawable_vision.self_location.x * SQUARE_SIZE[0] + SQUARE_SIZE[0]/2
end_y = drawable_vision.self_location.y * SQUARE_SIZE[1] + SQUARE_SIZE[1]/2
painter.drawLine(start_x, start_y, end_x, end_y)
return end_x, end_y
for point in self.snake.snake_array:
painter.drawRect(point.x * SQUARE_SIZE[0], # Upper left x-coord
point.y * SQUARE_SIZE[1], # Upper left y-coord
SQUARE_SIZE[0], # Width
SQUARE_SIZE[1]) # Height
if self.draw_vision:
start = self.snake.snake_array[0]
if self.snake._drawable_vision[0]:
for drawable_vision in self.snake._drawable_vision:
start_x = start.x * SQUARE_SIZE[0] + SQUARE_SIZE[0]/2
start_y = start.y * SQUARE_SIZE[1] + SQUARE_SIZE[1]/2
if drawable_vision.apple_location and drawable_vision.self_location:
apple_dist = self._calc_distance(start.x, drawable_vision.apple_location.x, start.y, drawable_vision.apple_location.y)
self_dist = self._calc_distance(start.x, drawable_vision.self_location.x, start.y, drawable_vision.self_location.y)
if apple_dist <= self_dist:
start_x, start_y = _draw_line_to_apple(painter, start_x, start_y, drawable_vision)
start_x, start_y = _draw_line_to_self(painter, start_x, start_y, drawable_vision)
else:
start_x, start_y = _draw_line_to_self(painter, start_x, start_y, drawable_vision)
start_x, start_y = _draw_line_to_apple(painter, start_x, start_y, drawable_vision)
elif drawable_vision.apple_location:
start_x, start_y = _draw_line_to_apple(painter, start_x, start_y, drawable_vision)
elif drawable_vision.self_location:
start_x, start_y = _draw_line_to_self(painter, start_x, start_y, drawable_vision)
if drawable_vision.wall_location:
painter.setPen(QtGui.QPen(Qt.black))
end_x = drawable_vision.wall_location.x * SQUARE_SIZE[0] + SQUARE_SIZE[0]/2
end_y = drawable_vision.wall_location.y * SQUARE_SIZE[1] + SQUARE_SIZE[1]/2
painter.drawLine(start_x, start_y, end_x, end_y)