From 3a6d7ae421ad2b650cac7f17d43be313787f0e61 Mon Sep 17 00:00:00 2001 From: tassaron Date: Sun, 2 Jul 2017 21:38:19 -0400 Subject: frame-drawing tools for components to share --- src/components/text.py | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'src/components/text.py') diff --git a/src/components/text.py b/src/components/text.py index 6be3120..97d7d07 100644 --- a/src/components/text.py +++ b/src/components/text.py @@ -1,11 +1,10 @@ from PIL import Image, ImageDraw -from PyQt5.QtGui import QPainter, QColor, QFont +from PyQt5.QtGui import QColor, QFont from PyQt5 import QtGui, QtCore, QtWidgets -from PIL.ImageQt import ImageQt import os -import sys from component import Component +from frame import FramePainter class Component(Component): @@ -131,22 +130,14 @@ class Component(Component): def addText(self, width, height): x, y = self.getXY() - im = self.blankFrame(width, height) - image = ImageQt(im) + image = FramePainter(width, height) - painter = QPainter(image) self.titleFont.setPixelSize(self.fontSize) - painter.setFont(self.titleFont) - if sys.byteorder == 'big': - painter.setPen(QColor(*self.textColor)) - else: - painter.setPen(QColor(*self.textColor[::-1])) - painter.drawText(x, y, self.title) - painter.end() + image.setFont(self.titleFont) + image.setPen(self.textColor) + image.drawText(x, y, self.title) - imBytes = image.bits().asstring(image.byteCount()) - - return Image.frombytes('RGBA', (width, height), imBytes) + return image.finalize() def pickColor(self): RGBstring, btnStyle = super().pickColor() -- cgit v1.2.3