Python Forum
[closed] "checked" variable (attribute?) origin?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[closed] "checked" variable (attribute?) origin?
#1
Hi

I've found this small snippet, and in the the_button_was_toggled method, i do not understand from where the checked variable (attribute?) come from? Is it an inheritance?

Thanks

import sys

from PySide6.QtWidgets import (QApplication,
                               QMainWindow,
                               QPushButton,
                              )


class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        self.setWindowTitle("My App")

        button = QPushButton("Press Me!")
        button.setCheckable(True)
        button.clicked.connect(self.the_button_was_clicked)
        button.clicked.connect(self.the_button_was_toggled)

        # Set the central widget of the Window.
        self.setCentralWidget(button)

    def the_button_was_clicked(self):
        print("Clicked!")

    def the_button_was_toggled(self, checked):
        print("Checked?", checked)


app = QApplication(sys.argv)

window = MainWindow()
window.show()

app.exec()
Reply


Messages In This Thread
[closed] "checked" variable (attribute?) origin? - by paul18fr - Feb-28-2024, 01:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  tkinter checkbutton if checked MC2020 2 6,063 Jan-21-2020, 07:08 PM
Last Post: joe_momma
  [Tkinter] Extrakt a Variable from a closed tkinter window hWp 5 3,878 Aug-23-2019, 09:01 PM
Last Post: woooee
  [WxPython] how to reopen a closed tab of wx.aui.Notebook? royer14 2 3,335 Feb-18-2019, 12:31 AM
Last Post: royer14
  [Tkinter] Completing Action when CheckBox is Checked Anysja 2 8,046 Aug-02-2018, 04:38 PM
Last Post: Anysja
  [Tkinter] Displaying an image that can't be closed nicochulo 4 3,685 Feb-15-2018, 10:27 AM
Last Post: nicochulo
  [PyQt] Whole application is closed by subwindows Alfalfa 1 7,434 Oct-03-2017, 03:22 PM
Last Post: Alfalfa
  doing something after been checked a checkbutton gray 1 4,327 Feb-18-2017, 05:11 PM
Last Post: Axel_Erfurt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020