本文整理汇总了Python中PyQt5.QtCore.Qt.transparent方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.transparent方法的具体用法?Python Qt.transparent怎么用?Python Qt.transparent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.Qt
的用法示例。
在下文中一共展示了Qt.transparent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import transparent [as 别名]
def __init__(self, engine=None, parent=None):
super(DQuickView, self).__init__(engine, parent)
self.setResizeMode(QtQuick.QQuickView.SizeViewToRootObject)
self.engine().addImportPath(os.sep.join([get_parent_dir(__file__, 2),
'qml']))
if isWebengineUsed:
# self.initWebengine()
pass
format = QSurfaceFormat()
format.setAlphaBufferSize(8)
format.setRenderableType(QSurfaceFormat.OpenGL)
self.setFormat(format)
self.setColor(QColor(Qt.transparent))
self.setClearBeforeRendering(True)
示例2: createPixmapFromNinePatchImage
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import transparent [as 别名]
def createPixmapFromNinePatchImage(image, dw, dh):
w = dw
h = dh
if w < image.width() or h < image.height(): # shrink
w = max(image.width(), w)
h = max(image.height(), h)
pm1 = resize9patch(image, w, h)
if pm1.isNull():
return QPixmap()
pm2 = QPixmap(dw, dh)
pm2.fill(Qt.transparent)
pr = QPainter(pm2)
pr.setRenderHint(QPainter.Antialiasing)
pr.setRenderHint(QPainter.SmoothPixmapTransform)
pr.drawPixmap(0, 0, dw, dh, pm1, 0, 0, w, h)
return pm2
else:
return resize9patch(image, dw, dh)
示例3: startDrag
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import transparent [as 别名]
def startDrag(self, supportedActions):
items = self.selectedItems()
drag = QDrag(self)
mimeData = self.mimeData(items)
# 由于QMimeData只能设置image、urls、str、bytes等等不方便
# 这里添加一个额外的属性直接把item放进去,后面可以根据item取出数据
mimeData.setProperty('myItems', items)
drag.setMimeData(mimeData)
pixmap = QPixmap(self.viewport().visibleRegion().boundingRect().size())
pixmap.fill(Qt.transparent)
painter = QPainter()
painter.begin(pixmap)
for item in items:
rect = self.visualRect(self.indexFromItem(item))
painter.drawPixmap(rect, self.viewport().grab(rect))
painter.end()
drag.setPixmap(pixmap)
drag.setHotSpot(self.viewport().mapFromGlobal(QCursor.pos()))
drag.exec_(supportedActions)
示例4: __init__
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import transparent [as 别名]
def __init__(self, *args, fillcolor, opacity, parent=None):
if len(args) == 0:
super().__init__(parent)
elif len(args) == 1:
super().__init__(args[0], parent)
elif len(args) == 4:
x0, y0, w, h = args
super().__init__(x0, y0, w, h, parent)
self.finished = False
self.selected_edge = None # type: int
self.resizing = False
self.setBrush(fillcolor)
self.setPen(QPen(QColor(Qt.transparent), 0))
self.setOpacity(opacity)
示例5: paint
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import transparent [as 别名]
def paint(self, painter, option, widget):
if self.scene().mode == 1:
self.setOpacity(1 if self.model_item.logging_active else 0.3)
if self.hover_active or self.isSelected():
painter.setOpacity(settings.SELECTION_OPACITY)
painter.setBrush(settings.SELECTION_COLOR)
painter.setPen(QPen(QColor(Qt.transparent), 0))
painter.drawRect(self.boundingRect())
elif not self.is_valid():
painter.setOpacity(settings.SELECTION_OPACITY)
painter.setBrush(QColor(255, 0, 0, 150))
painter.setPen(QPen(QColor(Qt.transparent), 0))
painter.drawRect(self.boundingRect())
if self.drag_over:
self.paint_drop_indicator(painter)
示例6: resetPreviewer
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import transparent [as 别名]
def resetPreviewer(self):
pix = QPixmap(333, 333)
pix.fill(Qt.transparent)
self.preview.setPixmap(pix)
示例7: __init__
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import transparent [as 别名]
def __init__(self, *args, **kwargs):
palette = self.palette()
if sys.platform == 'linux':
# KDE use the QPalette.Base as background color
palette.setColor(QPalette.Active, QPalette.Base, Qt.transparent)
palette.setColor(QPalette.Inactive, QPalette.Base, Qt.transparent)
# GNOME use the QPalette.Window as background color
palette.setColor(QPalette.Active, QPalette.Window, Qt.transparent)
palette.setColor(QPalette.Inactive, QPalette.Window, Qt.transparent)
else:
# macOS use the QPalette.Window as background color
palette.setColor(QPalette.Active, QPalette.Window, Qt.transparent)
palette.setColor(QPalette.Inactive, QPalette.Window, Qt.transparent)
self.setPalette(palette)
示例8: pixmap
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import transparent [as 别名]
def pixmap(self, size, mode, state):
pixmap = QPixmap(size)
pixmap.fill(Qt.transparent)
self.paint(QPainter(pixmap), QRect(QPoint(0, 0), size), mode, state)
return pixmap
示例9: gradientCirclePixmap
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import transparent [as 别名]
def gradientCirclePixmap(self):
"""白色带阴影
"""
xy = self.height() / 2
radius = self.height() * 0.8
# 绘制普通状态下圆形的滑块
circleColor = QRadialGradient(xy, xy, radius, xy, xy)
circleColor.setColorAt(0.5, QColor(254, 254, 254))
circleColor.setColorAt(0.7, QColor(0, 0, 0, 60))
circleColor.setColorAt(0.7, QColor(0, 0, 0, 30))
circleColor.setColorAt(0.9, QColor(0, 0, 0, 0))
self._imageCircle = QImage(
self.height(), self.height(), QImage.Format_ARGB32)
self._imageCircle.fill(Qt.transparent)
painter = QPainter()
painter.begin(self._imageCircle)
painter.setRenderHint(QPainter.Antialiasing, True)
painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
painter.setPen(Qt.NoPen)
painter.setBrush(circleColor)
painter.drawRoundedRect(0, 0, self.height(), self.height(), xy, xy)
painter.end()
# 绘制悬停状态下圆形的滑块
circleColorHover = QRadialGradient(xy, xy, radius, xy, xy)
circleColorHover.setColorAt(0.5, QColor(245, 245, 245))
circleColorHover.setColorAt(0.7, QColor(0, 0, 0, 30))
circleColorHover.setColorAt(0.9, QColor(0, 0, 0, 0))
self._imageCircleHover = QImage(
self.height(), self.height(), QImage.Format_ARGB32)
self._imageCircleHover.fill(Qt.transparent)
painter = QPainter()
painter.begin(self._imageCircleHover)
painter.setRenderHint(QPainter.Antialiasing, True)
painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
painter.setPen(Qt.NoPen)
painter.setBrush(circleColorHover)
painter.drawRoundedRect(0, 0, self.height(), self.height(), xy, xy)
painter.end()
示例10: _createPointer
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import transparent [as 别名]
def _createPointer(self):
# 绘制一个小圆环
self._imagePointer = QImage(12, 12, QImage.Format_ARGB32)
self._imagePointer.fill(Qt.transparent)
painter = QPainter()
painter.begin(self._imagePointer)
painter.setRenderHint(QPainter.Antialiasing, True)
painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
painter.setPen(QPen(Qt.white, 2))
painter.setBrush(Qt.NoBrush)
path = QPainterPath()
path.addRoundedRect(0, 0, 12, 12, 6.0, 6.0)
painter.setClipPath(path)
painter.drawRoundedRect(0, 0, 12, 12, 6.0, 6.0)
painter.end()
示例11: __init__
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import transparent [as 别名]
def __init__(self, app_window):
super(ScriptsDialog, self).__init__(app_window)
self.script = None
self._app_window = app_window
self._script_manager = ScriptsManager()
self._git = Git()
self.setMinimumWidth(800)
box = QVBoxLayout()
self.table = ScriptsTable(self)
self.table.onScriptSelected.connect(self._item_selected)
self.table.setMinimumWidth(800)
# create a centered dot icon
_section_width = self.table.header().sectionSize(3)
self._new_pixmap = QPixmap(max(_section_width, 40), 20)
self._new_pixmap.fill(Qt.transparent)
painter = QPainter(self._new_pixmap)
rect = QRect((_section_width * 0.5) - 5, 0, 20, 20)
painter.setBrush(QColor('#666'))
painter.setPen(QColor('#666'))
painter.drawEllipse(rect)
self._dot_icon = QIcon(self._new_pixmap)
box.addWidget(self.table)
lbl = QLabel('OS Support - A: Android I: IOS W: Windows')
box.addWidget(lbl)
self.setLayout(box)
self._init_list()
示例12: draw_line_numbers
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import transparent [as 别名]
def draw_line_numbers(self, event):
painter = QPainter(self.ui_line_numbers)
# background
painter.fillRect(event.rect(), Qt.transparent)
# linenums
current_block = self.firstVisibleBlock()
block_num = current_block.blockNumber()
top = self.blockBoundingGeometry(current_block).translated(
self.contentOffset()).top()
bottom = top + self.blockBoundingRect(current_block).height()
while current_block.isValid() and (top <= event.rect().bottom()):
if current_block.isVisible() and (bottom >= event.rect().top()):
s = ("{0}".format(block_num + 1))
painter.setPen(QColor('#636d83'))
painter.setFont(self.font())
painter.drawText(0, top,
self.calculated_linenum_width() - 5,
self.fontMetrics().height(),
Qt.AlignRight | Qt.AlignVCenter, s)
current_block = current_block.next()
top = bottom
bottom = top + self.blockBoundingRect(current_block).height()
block_num += 1
示例13: __init__
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import transparent [as 别名]
def __init__(self, *args, antialiasing=True, **kwargs):
super(Label, self).__init__(*args, **kwargs)
self.Antialiasing = antialiasing
self.setMaximumSize(200, 200)
self.setMinimumSize(200, 200)
self.radius = 100
#####################核心实现#########################
self.target = QPixmap(self.size()) # 大小和控件一样
self.target.fill(Qt.transparent) # 填充背景为透明
p = QPixmap("Data/Images/head.jpg").scaled( # 加载图片并缩放和控件一样大
200, 200, Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation)
painter = QPainter(self.target)
if self.Antialiasing:
# 抗锯齿
painter.setRenderHint(QPainter.Antialiasing, True)
painter.setRenderHint(QPainter.HighQualityAntialiasing, True)
painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
# painter.setPen(# 测试圆圈
# QPen(Qt.red, 5, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
path = QPainterPath()
path.addRoundedRect(
0, 0, self.width(), self.height(), self.radius, self.radius)
# **** 切割为圆形 ****#
painter.setClipPath(path)
# painter.drawPath(path) # 测试圆圈
painter.drawPixmap(0, 0, p)
self.setPixmap(self.target)
#####################核心实现#########################
示例14: clearChart
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import transparent [as 别名]
def clearChart(self):
self.color = QColor(Qt.transparent)
self.update()
self.chartCleared.emit() # 发射信号
示例15: onScreenShot1
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import transparent [as 别名]
def onScreenShot1(self):
# 截图方式1
page = self.webView.page()
oldSize = self.webView.size()
self.webView.resize(page.contentsSize().toSize())
def doScreenShot():
rect = self.webView.contentsRect()
size = rect.size()
image = QImage(size, QImage.Format_ARGB32_Premultiplied)
image.fill(Qt.transparent)
painter = QPainter()
painter.begin(image)
painter.setRenderHint(QPainter.Antialiasing, True)
painter.setRenderHint(QPainter.TextAntialiasing, True)
painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
self.webView.render(painter)
painter.end()
self.webView.resize(oldSize)
# 添加到左侧list中
item = QListWidgetItem(self.widgetRight)
image = QPixmap.fromImage(image)
item.setIcon(QIcon(image))
item.setData(Qt.UserRole + 1, image)
# 先等一下再截图吧
QTimer.singleShot(2000, doScreenShot)