I made a pop-up. It is basically some rows of options (max. 5 rows).
If I press the '+' button, there will be a new line of options.
If I press the '-' button the last row should diasappear. Unfortunatelly it doesn't.
I tried already the followings out in root.remove():
--> widget_path.pop(0) : no visual change, I see n rows instead of n-1 .
--> widget_path.pop() : It removes the first line instead of the last one.
--> Gridlayout (cols: 4) instead of StackLayout: similar results
Could you help me?
Here is my code:
.kv -file;
<FormPopup>:size_hint: None, Nonesize: '361pt', '220pt'BoxLayout:orientation: 'vertical'BoxLayout:size_hint: 1, Noneheight: '20pt'orientation: 'horizontal'Label:text: 'column1'Label:text: 'column2'Label:text: 'column3'Label:text: 'column4'# list of sensorsStackLayout:padding: 0spacing: 1orientation: 'lr-tb'pos_hint: {'center_x': .5, 'center_y': .5}height: self.minimum_heightid: measure_stackBoxLayout:orientation: 'horizontal'MyButton:text: '+'on_release: root.add()MyButton:text: '-'on_release: root.remove()
my .py class:
class FormPopup(Popup):"""Class: Popup for comments"""def __init__(self):super().__init__()self.error = 0self.linenumber = 0self.add()def add(self):"""add a new option-line"""widget_path = self.idsif self.linenumber < 5 :sensor_id = 'sensor_' + str(self.linenumber)widget_path['measure_stack'].add_widget(Spinner(id = sensor_id, size_hint=(None,None), height='20pt', width='85pt', text = '---', values= ('A','B','C') ))measurand_id = 'measurand_' + str(self.linenumber)widget_path['measure_stack'].add_widget(Spinner(id = measurand_id, size_hint=(None,None), height='20pt', width='85pt', text = '---', values= ('A','B','C') ) )branchwise_id = 'branchwise_' + str(self.linenumber)widget_path['measure_stack'].add_widget(Spinner(id = branchwise_id, size_hint=(None,None), height='20pt', width='85pt', text = '---', values= ('A','B','C')))procedure_id = 'procedure_' + str(self.linenumber)widget_path['measure_stack'].add_widget(Spinner(id = procedure_id, size_hint=(None,None), height='20pt', width='85pt', text = '---', values= ('A','B','C'))) self.linenumber += 1def remove(self):"""remove one option-line"""widget_path = self.ids.measure_stack.children# do not remove if there is only one lineif len(widget_path) > 4:self.linenumber -= 1for i in range(4):widget_path.pop(0)