vendredi 31 juillet 2020

How to call back checkboxs in kivy?

self.t_and_c = Label(text='Accept terms and conditions: ') self.inside.add_widget(self.t_and_c)

    self.checkbox_first = CheckBox(active=False)
    self.checkbox_first.bind(active = self.checkbox_status)
    self.inside.add_widget(self.checkbox_first)
    
    self.pvt_policy = Label(text='Accept private policy: ')
    self.inside.add_widget(self.pvt_policy)
    
    self.checkbox_second = CheckBox(active=False)
    self.checkbox_second.bind(active = self.checkbox_status)
    
    self.inside.add_widget(self.checkbox_second)
    self.inside.add_widget(Label())
    self.enter = Button(text='Enter information', disabled=True)
    self.inside.add_widget(self.enter)
    
    
def checkbox_status(self, instance):
    if self.checkbox_first.active == True and self.checkbox_second.active == True:
        self.enter.disabled == False
    else:
        self.enter.disabled == True

I want to create a function which disables a button until two checkboxes have been 'checked'. I am trying to call the checkbox but I get this error:

TypeError: checkbox_status() takes 2 positional arguments but 3 were given

I am confused as to why I would need another input argument, any help is appreciated but please could the answer be given in the Python language rather than kv?




Aucun commentaire:

Enregistrer un commentaire