Created
October 11, 2021 18:06
-
-
Save jeremysanders/a83b7ecaa674cd11095dc2cf0c239ed0 to your computer and use it in GitHub Desktop.
example program with rotated text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
from PyQt5.QtCore import * | |
from PyQt5.QtGui import * | |
from PyQt5.QtWidgets import * | |
class Win(QWidget): | |
def paintEvent(self, event): | |
font = QFont("Bitstream Vera Serif", 50) | |
font.setItalic(True) | |
painter = QPainter(self) | |
painter.setFont(font) | |
painter.save() | |
painter.translate(100, 450) | |
painter.scale(0.7, 0.7) | |
painter.rotate(270) | |
painter.drawText(0, 0, "Scaled text") | |
painter.restore() | |
painter.save() | |
painter.translate(200, 450) | |
painter.rotate(270) | |
painter.drawText(0, 0, "Original size") | |
painter.restore() | |
app = QApplication(sys.argv) | |
win = Win() | |
win.show() | |
app.exec_() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you, you helped me with my school project!