Last active
November 25, 2019 23:21
-
-
Save zed/62227e5e360fd2a5316c74af9497f42b to your computer and use it in GitHub Desktop.
This file contains 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 | |
"""Draw text in the center of the screen.""" | |
import sys | |
from PyQt5.QtCore import Qt | |
from PyQt5.QtGui import QFont | |
from PyQt5.QtWidgets import QApplication, QLabel | |
app = QApplication(sys.argv) | |
w = QLabel() | |
w.setWindowFlags(Qt.FramelessWindowHint) | |
w.setAttribute(Qt.WA_TranslucentBackground) | |
w.setText("Draw text...") | |
w.setFont(QFont("Times", 25, QFont.Normal)) | |
# w.move(x, y) or center | |
w.adjustSize() # update w.rect() now | |
w.move(app.desktop().screen().rect().center() - w.rect().center()) | |
w.show() | |
sys.exit(app.exec_()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment