1 - Création d'un QLabelPyQt5 Pour créer des label au sein d'une feêtre, PyQt5 nous offre la classe QLabel. Il suffit d'instancier cette classe en ajoutant le container parent comme paramère:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
import sys from PyQt5.QtWidgets import QApplication, QWidget, QLabel app = QApplication(sys.argv) widget = QWidget() widget.setGeometry(50,50,320,200) widget.setWindowTitle("Label Example") # create a QLabel qlabel = QLabel(widget) qlabel.setText("Hello World !") # define the qlabel dimensions & position qlabel.setGeometry(50 , 50 , 200 , 50) widget.show() sys.exit(app.exec_()) |
Ce qui affiche à l'execution: 2 - Utiliser un style de designe pour un QLabel Un objet QLabel est doté de la méthode…