Skip to content

Instantly share code, notes, and snippets.

@jeremysanders
Created October 11, 2021 18:06
Show Gist options
  • Save jeremysanders/a83b7ecaa674cd11095dc2cf0c239ed0 to your computer and use it in GitHub Desktop.
Save jeremysanders/a83b7ecaa674cd11095dc2cf0c239ed0 to your computer and use it in GitHub Desktop.
example program with rotated text
#!/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_()
@Zdertis420
Copy link

Thank you, you helped me with my school project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment