#pythontutorial #python #pyqt5
PyQt5 QLabels
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel
from PyQt5.QtGui import QFont
from PyQt5.QtCore import Qt
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setGeometry(700, 300, 500, 500)
label = QLabel("Hello", self)
label.setFont(QFont("Arial", 40))
label.setGeometry(0, 0, 500, 100)
label.setStyleSheet("color: #292929;"
"background-color: #6fdcf7;"
"font-weight: bold;"
"font-style: italic;"
"text-decoration: underline;")
label.setAlignment(Qt.AlignTop) # VERTICALLY TOP
label.setAlignment(Qt.AlignBottom) # VERTICALLY BOTTOM
label.setAlignment(Qt.AlignVCenter) # VERTICALLY CENTER
label.setAlignment(Qt.AlignRight) # HORIZONTALLY RIGHT
label.setAlignment(Qt.AlignHCenter) # HORIZONTALLY CENTER
label.setAlignment(Qt.AlignLeft) # HORIZONTALLY LEFT
label.setAlignment(Qt.AlignHCenter | Qt.AlignTop) # CENTER & TOP
label.setAlignment(Qt.AlignHCenter | Qt.AlignBottom) # CENTER & BOTTOM
label.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) # CENTER & CENTER
label.setAlignment(Qt.AlignCenter) # CENTER & CENTER
def main():
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()
On this page of the site you can watch the video online Create LABELS with Python in 8 minutes! 🏷️ with a duration of hours minute second in good quality, which was uploaded by the user Bro Code 24 July 2024, share the link with friends and acquaintances, this video has already been watched 20,425 times on youtube and it was liked by 348 viewers. Enjoy your viewing!