From c772bf5583dec23513371392ca6d2018518483cb Mon Sep 17 00:00:00 2001 From: Maximilian Siess Date: Tue, 18 Apr 2017 13:35:29 +0200 Subject: Added text alignment option --- core.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'core.py') diff --git a/core.py b/core.py index 895d1a9..6bd533d 100644 --- a/core.py +++ b/core.py @@ -26,7 +26,7 @@ class Core(): except: return "avconv" - def drawBaseImage(self, backgroundImage, titleText, titleFont): + def drawBaseImage(self, backgroundImage, titleText, titleFont, alignment): if self._image == None or not self.lastBackgroundImage == backgroundImage: self.lastBackgroundImage = backgroundImage @@ -49,7 +49,13 @@ class Core(): painter.setFont(font) painter.setPen(QColor(255, 255, 255)) - painter.drawText(70, 375, titleText) + fm = QtGui.QFontMetrics(font) + if alignment == "Left": + painter.drawText(70, 375, titleText) + if alignment == "Middle": + painter.drawText(1280/2 - fm.width(titleText)/2, 375, titleText) + if alignment == "Right": + painter.drawText(1210 - fm.width(titleText), 375, titleText) painter.end() buffer = QtCore.QBuffer() -- cgit v1.2.3