diff options
| author | tassaron | 2017-07-02 21:38:19 -0400 |
|---|---|---|
| committer | tassaron | 2017-07-02 21:38:19 -0400 |
| commit | 3a6d7ae421ad2b650cac7f17d43be313787f0e61 (patch) | |
| tree | 1788ad881bb621d6d3bc2962d3d8b65e9f952522 /src/components/text.py | |
| parent | 0da275bf1b1dd2c956fed9d4a1051dcf3365c382 (diff) | |
frame-drawing tools for components to share
Diffstat (limited to 'src/components/text.py')
| -rw-r--r-- | src/components/text.py | 23 |
1 files changed, 7 insertions, 16 deletions
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() |
