mardi 28 février 2023

Getting CheckBox checked state in a Python FMX GUI app

I've created a small app in the DelphiFMX GUI library for Python that has a Checkbox, Button, and Label on it:

Python GUI form with checkbox, button and label

When I click on the button, then I simply want to check the checked state of the checkbox and then write into the label whether it is checked or not. I have the following code currently for clicking on the button, but it doesn't work:

def Button_OnClick(self, sender):
    if self.myCheckBox.Checked:
        self.myLabel.Text = "The Checkbox is Checked"
    else:
        self.myLabel.Text = "The Checkbox is Unchecked"

When I click on the button, then I get the following run-time error AttributeError: Error in getting property "Checked". Error: Unknown attribute:

AttributeError: Error in getting property "Checked". Error: Unknown attribute

What is the correct or best way to get the Checked state of a CheckBox component?




Aucun commentaire:

Enregistrer un commentaire