23 lines
660 B
Python
23 lines
660 B
Python
from PyQt6.QtWidgets import QApplication, QLabel
|
|
from PyQt6.QtGui import QPixmap
|
|
import sys
|
|
import base64
|
|
|
|
app = QApplication(sys.argv)
|
|
|
|
def get_colored_svg_uri(path: str, color: str) -> str:
|
|
with open(path, 'r', encoding='utf-8') as f:
|
|
svg_content = f.read()
|
|
svg_content = svg_content.replace('currentColor', color)
|
|
b64 = base64.b64encode(svg_content.encode('utf-8')).decode('utf-8')
|
|
return f"data:image/svg+xml;base64,{b64}"
|
|
|
|
path = "third_party/Bootstrap/bootstrap-icons-1.13.1/reception-4.svg"
|
|
uri = get_colored_svg_uri(path, "#a0d8a0")
|
|
|
|
label = QLabel()
|
|
label.setText(f"<img src='{uri}'> Hello")
|
|
label.show()
|
|
|
|
sys.exit(app.exec())
|