aboutsummaryrefslogtreecommitdiff
path: root/core.py
diff options
context:
space:
mode:
authorMaximilian SiessÂ2017-04-18 13:35:29 +0200
committerMaximilian SiessÂ2017-04-18 13:35:29 +0200
commitc772bf5583dec23513371392ca6d2018518483cb (patch)
tree1de8e0323662a494679d52212107840d861c9045 /core.py
parent7d2ecb0d1511f9918a951c995988e797d2971fd7 (diff)
Added text alignment option
Diffstat (limited to 'core.py')
-rw-r--r--core.py10
1 files changed, 8 insertions, 2 deletions
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()