Feb-28-2024, 04:26 PM
(This post was last modified: Feb-28-2024, 08:11 PM by deanhystad.)
Are you wondering wy button.clicked passes 1 argument (self) to "the_button_was_clicked" and two arguments to "the_button_was_toggled"?
I think your grabbed that snippet from here.
https://www.pythonguis.com/tutorials/pys...ts-events/
But this has a better description of signals and slots and how they relate to your particular example.
https://doc.qt.io/qtforpython-6.5/tutori...slots.html
The cliff notes version is the QPushButton.clicked signal has information about the toggled state of the button, even if the button cannot be toggled. When the clicked signal called "the_button_was_clicked()" the toggle state was not passed. When clicked signal called "the_button_was_toggled()", it passes the toggle state as a function argument. It knew to do this by inspecting the signature of the callback function.
I think your grabbed that snippet from here.
https://www.pythonguis.com/tutorials/pys...ts-events/
But this has a better description of signals and slots and how they relate to your particular example.
https://doc.qt.io/qtforpython-6.5/tutori...slots.html
The cliff notes version is the QPushButton.clicked signal has information about the toggled state of the button, even if the button cannot be toggled. When the clicked signal called "the_button_was_clicked()" the toggle state was not passed. When clicked signal called "the_button_was_toggled()", it passes the toggle state as a function argument. It knew to do this by inspecting the signature of the callback function.