android - Kivy Language Dynamic Checkbox List -


i want dyanmically add checkboxes in kivy languages. know how achieve in python unaware how in kivy language. there should checkbox each file in below list:

 kivy.uix.filechooser import filesystemlocal  file_system = filesystemlocal()  file_list=file_system.listdir(app.get_running_app().user_data_dir+'\\')   # returns list of files in dir  file_list=[x x in file_list if x[-4:]=='.csv'] 

how can loop kivy? assuming there should loop on right side, since python code. have no clue how? starters can helpful.

edit:

class mergescreen(screen):     result_label=''     check_boxes={}     def __init__(self,**kwargs):         self.name='mergescreen'         super(mergescreen, self).__init__(**kwargs)         b=boxlayout(orientation='vertical')         file_system = filesystemlocal()         file_list=file_system.listdir(app.get_running_app().user_data_dir+'\\')   # returns list of files in dir         file_list=[x x in file_list if x[-4:]=='.csv']         file_1 in file_list:             g=gridlayout(cols=2)             c=checkbox()             l=label(bold= true,font_size=20,text=file_1)             self.check_boxes[c]=file_1             g.add_widget(l);g.add_widget(c)             b.add_widget(g)         g=gridlayout(cols=2)         l=label(bold= true,font_size=20,text='result name')         t=textinput(font_size=25)         self.result_label=t         g.add_widget(l)         g.add_widget(t)         b.add_widget(g)         g_options=gridlayout(cols=2)         g_options.add_widget(button(text="okay",on_press=self.create_result))         g_options.add_widget(button(text="back",on_press=self.return_back))         b.add_widget(g_options)         self.add_widget(b)             def return_back(self,btn):         self.parent.current = 'experimentselectscreen'         def create_result(self,btn):         file_list=[]         root_dir= app.get_running_app().user_data_dir+'\\'         key, value in self.check_boxes.iteritems():             if key.active==true:                 file_list.append(root_dir+'\\'+value)         result_name=self.result_label.text+'.csv'         result_dir=root_dir+'results'         if os.path.exists(result_dir)==false:os.makedirs(result_dir)         result_path=result_dir+'\\'+result_name         fout=open(result_path,"w+")         # # first file:         line in open(file_list[0]):             fout.write(line)         # # rest:             num in file_list[0:]:             f = open(num)             f.next() # skip header             line in f:                 fout.write(line)             f.close() # not needed         fout.close()         file_create=popup(title='confirmation',content=label(text="merged file has stored at\n"+result_path)\                 ,size_hint=(.75,.75),auto_dismiss=true)         file_create.open()         clock.schedule_interval(file_create.dismiss, 3)  

the problem how can want add check boxes if file gets created, since init() run once. have restart app each time.

you can't dynamically add widgets in kv language, except in sense of writing self.add_widget(something()) in e.g. event binding such on_press. don't think it's fit you're doing though, sounds task should on python side.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -