from PyQt6.QtWidgets import *
from PyQt6.QtGui import *
import sys
class Window(QWidget):
def __init__(self):
super().__init__()
self.setGeometry(200,200, 700, 400)
self.setWindowTitle("PyQt6 QGridLayout")
self.setWindowIcon(QIcon('images/python.png'))
self.create_widget()
def create_widget(self):
hbox = QHBoxLayout()
btn = QPushButton()
btn.clicked.connect(self.clicked_btn)
self.label = QLabel("DefText")
hbox.addWidget(btn)
hbox.addWidget(self.label)
self.setLayout(hbox)
def clicked_btn(self):
self.label.setText("anotherText")
self.label.setFont(QFont("Times", 15))
self.label.setStyleSheet("color:red")
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec())