-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathicon.py
More file actions
32 lines (25 loc) · 908 Bytes
/
icon.py
File metadata and controls
32 lines (25 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import sys
from PyQt6.QtWidgets import QApplication
from PyQt6.QtGui import QIcon, QPixmap, QPainter, QColor, QFont
from PyQt6.QtCore import Qt, QSize
def create_icon():
# 创建一个32x32的图标
pixmap = QPixmap(32, 32)
pixmap.fill(Qt.GlobalColor.transparent)
painter = QPainter(pixmap)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
# 绘制圆形背景
painter.setBrush(QColor("#2C3E50"))
painter.setPen(Qt.PenStyle.NoPen)
painter.drawEllipse(0, 0, 32, 32)
# 绘制"T"字母
painter.setPen(QColor("white"))
painter.setFont(QFont("Arial", 16, QFont.Weight.Bold))
painter.drawText(8, 24, "T")
painter.end()
return QIcon(pixmap)
if __name__ == "__main__":
app = QApplication(sys.argv)
icon = create_icon()
icon.pixmap(QSize(32, 32)).save("icon.png")
sys.exit(0)