I am creating a mobile app as questionary, my questions are in checkboxes. functions in my app make a list of answers and when the user choose certain answer it writes value into list.
Sometimes they can choose wrong answer and they want to repair their choice. i want to add function when they unclick a checkbox to delete last value in list
in .py
class test:
def __init__(self, testovatel, test_v=[], ):
self.testovatel = testovatel
self.test_v = test_v
def mistake(self):
del self.test_v [len(self.test_v)-1]
class TestScreenV(Screen):
jarka= test("jarka")
def bad(self):
if self.ids.check_test.active == False:
self.jarka.mistake()
def d_plus(self):
self.jarka.test_v += ("d",)
def i_plus(self):
self.jarka.test_v += ('i',)
def s_plus(self):
self.jarka.test_v +=('s',)
def k_plus(self):
self.jarka.test_v +=('k',)
in .kv
<TestConfirm>
on_release: root.set_icon(check_test)
CheckboxLeftWidget:
id: check_test
<TestScreenV>:
OneLineListItem:
text: "1/24 "
TestConfirm:
text: "bla"
on_press:
root.d_plus()
root.bad()
TestConfirm:
text: "bla"
on_press:
root.k_plus()
root.bad()
TestConfirm:
text: "bla"
on_press:
root.s_plus()
root.bad()
TestConfirm:
text: "bla"
on_press:
root.i_plus()
root.bad()
Aucun commentaire:
Enregistrer un commentaire