from PyQt5.QtWidgets import QApplication, QPushButton, QMessageBox app = QApplication([]) button = QPushButton('Click me!') def on_button_clicked(): alert = QMessageBox() alert.setText('Button clicked!') alert.exec_() button.clicked.connect(on_button_clicked) button.show() app.exec_()This example creates a QPushButton widget with the label "Click me!" and connects its clicked signal to a function `on_button_clicked()`. When the button is clicked, this function is called, which creates and displays a QMessageBox with the message "Button clicked!"