Python Forum
[closed] "checked" variable (attribute?) origin?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[closed] "checked" variable (attribute?) origin?
#4
Ok I think I finally figured out: if I want something to be printed (or checked) when the signal is sent, one need to define a variable that "sets" the boolean.

import sys
from PySide6.QtWidgets import QApplication, QPushButton


def Anyfunction(AnyArg_JustSomething):
    print(f"AnyArg_JustSomething  = {AnyArg_JustSomething}")


if __name__ == '__main__':
    app = QApplication(sys.argv)

    button = QPushButton("press me to send a signal")
    
    button.setCheckable(True)           # must be set to True to allow signal(s)
    button.toggled.connect(Anyfunction)    # signal

    button.show()
    sys.exit(app.exec())
Output:
AnyArg_JustSomething = True AnyArg_JustSomething = False AnyArg_JustSomething = True AnyArg_JustSomething = False AnyArg_JustSomething = True AnyArg_JustSomething = False ...
Gribouillis likes this post
Reply


Messages In This Thread
RE: [closed] "checked" variable (attribute?) origin? - by paul18fr - Mar-04-2024, 10:32 AM

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