BUH_bot/create_icon.py

69 lines
1.9 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Скрипт для создания иконки приложения
Создает PNG и ICO файлы с логотипом МойСклад
"""
from PyQt6.QtGui import QPixmap, QPainter, QColor
from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import QApplication
import sys
def create_icon():
"""Создание иконки приложения"""
app = QApplication(sys.argv)
# Создаем PNG иконку
pixmap = QPixmap(256, 256)
pixmap.fill(Qt.GlobalColor.transparent)
painter = QPainter(pixmap)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
# Рисуем круг с градиентом (синий цвет МойСклад)
painter.setBrush(QColor(52, 152, 219))
painter.setPen(Qt.PenStyle.NoPen)
painter.drawEllipse(8, 8, 240, 240)
# Рисуем текст "МС"
painter.setPen(QColor(255, 255, 255))
font = painter.font()
font.setPixelSize(140)
font.setBold(True)
painter.setFont(font)
painter.drawText(pixmap.rect(), Qt.AlignmentFlag.AlignCenter, 'МС')
painter.end()
# Сохраняем PNG
pixmap.save('app_icon.png')
print('✓ PNG иконка создана: app_icon.png')
# Конвертируем в ICO
try:
from PIL import Image
img = Image.open('app_icon.png')
img.save(
'app_icon.ico',
format='ICO',
sizes=[
(256, 256),
(128, 128),
(64, 64),
(48, 48),
(32, 32),
(16, 16)
]
)
print('✓ ICO иконка создана: app_icon.ico')
except ImportError:
print('⚠ Pillow не установлен, ICO файл не создан')
print(' Установите: pip install Pillow')
app.quit()
if __name__ == '__main__':
create_icon()