#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()
Watch video Python PyQt5 LABELS are easy! 🏷️ online, duration hours minute second in high quality that is uploaded to the channel Bro Code 24 July 2024. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 7,410 times and liked it 156 visitors.