PyQt5 Push Button

Push button widget QPushButton is a command button in PyQt5. It is clicked by the user to command the PC to perform some specific action, like Apply, Cancel and Save.

Push Button - QPushButton
import sys
from PyQt5 import QtWidgets

def basicWindow():
    app = QtWidgets.QApplication(sys.argv)
    windowExample = QtWidgets.QWidget()
    buttonA = QtWidgets.QPushButton(windowExample)
    labelA = QtWidgets.QLabel(windowExample)
    labelA.setText('Show Label')
    windowExample.setWindowTitle('Push Button Example')
    buttonA.move(100, 50)
    labelA.move(110, 100)
    windowExample.setGeometry(100, 100, 300, 200)



buttonA = QtWidgets.QPushButton(windowExample)

buttonA is the QPushButton from QtWidgets and it should be added to the window windowExample the same as labels introduced in last chapters.


It sets the text of buttonA to be Click!.

PyQt5 Push Button

It’s actually not going to do anything。