import sys from PyQt5.QtWidgets import QMainWindow, QPushButton, QApplication def the_button_was_clicked(): print("Button was clicked") def the_button_was_toggled(is_checked): print("Checked?", is_checked) class MainWindow(QMainWindow): def __init__(self): super().__init__() self.setWindowTitle("My App") button = QPushButton("Press Me!") button.setCheckable(True) button.clicked.connect(the_button_was_clicked) button.clicked.connect(the_button_was_toggled) # Set the central widget of the window self.setCentralWidget(button) app = QApplication(sys.argv) window = MainWindow() window.show() app.exec_()