Make button checkable

This commit is contained in:
Toast 2024-10-20 02:01:26 +02:00
parent 8b447c240c
commit 0692a45f09

View file

@ -12,6 +12,9 @@ class leekMainWindow(QMainWindow):
self.setWindowTitle("Leek!") self.setWindowTitle("Leek!")
button = QPushButton("Press Me!") button = QPushButton("Press Me!")
button.setCheckable(True)
button.clicked.connect(self.button_clicked)
button.clicked.connect(self.button_toggled)
self.setMaximumSize(QSize(800,600)) self.setMaximumSize(QSize(800,600))
self.setMinimumSize(QSize(400,300)) self.setMinimumSize(QSize(400,300))
@ -19,6 +22,12 @@ class leekMainWindow(QMainWindow):
# Set the central widget of the Window. # Set the central widget of the Window.
self.setCentralWidget(button) self.setCentralWidget(button)
def button_clicked(self):
print("Button was clicked")
def button_toggled(self, checked):
print("Checked?", checked )
def main(): def main():
# If you know you won't use command line arguments QApplication([]) works too. # If you know you won't use command line arguments QApplication([]) works too.