class MDListBottomSheet(MDBottomSheet): mlist = ObjectProperty() def __init__(self, **kwargs): super(MDListBottomSheet, self).__init__(**kwargs) self.mlist = MDList() self.gl_content.add_widget(self.mlist) Clock.schedule_once(self.resize_content_layout, 0) def resize_content_layout(self, *largs): self.gl_content.height = self.mlist.height def add_item(self, text, callback, icon=None): if icon: item = OneLineIconListItem(text=text, on_release=callback) item.add_widget(ListBSIconLeft(icon=icon)) else: item = OneLineListItem(text=text, on_release=callback) item.bind(on_release=lambda x: self.dismiss()) self.mlist.add_widget(item)
def on_enter(self, *args): blayout = MyLayout() resview = ScrollView() mylist = MDList() count = 0 title = authors = 'Not Available' bsrc = 'Image-not-available.jpg' for i in self.parent.result: #print('\n'+i+'\n') try: title = i['volumeInfo']['title'] except: pass try: authors = i['volumeInfo']['authors'] except: pass try: bsrc = i['volumeInfo']['imageLinks']['smallThumbnail'] except: pass item = TwoLineAvatarIconListItem(text=title, secondary_text=str(authors)) item.add_widget(BookPhoto(source=bsrc)) item.bind(on_press=partial(self.change_screen, count)) mylist.add_widget(item) count += 1 resview.add_widget(mylist) blayout.add_widget(resview) self.add_widget(blayout)
def build_screen(self): history = JsonStore(history_path) scrollview = ScrollView(do_scroll_x=False) md_list = MDList() scrollview.add_widget(md_list) for i in history.keys(): item = HistoryItem(text=str(i)) item.add_widget( AvatarSampleWidget(source="./assets/kivy-icon-128.png")) md_list.add_widget(item) print("building screen for history") self.add_widget(scrollview)
def show_files_extensions(self, file_type): ''' Loads the files extension settings from the assets/file_extension.json it is called when either 'Document, Video, Image or Audoi' List items is pressed. After loading, it is shown in a dialog :parameters: file_type --> extension key in the json_file e.g 'document_extensions :return: opens a dialog ''' files_extension = JsonStore('assets/files_extension.json') dialog_content = MDList() self.dialog = None for extension in files_extension.get(file_type): # trim '.' from the file extension e.g. '.pdf', and add doc_ext_ # to itso it becomes 'doc_ext_pdf' and use it as the widget id. icon_right_sample_widget = IconRightSampleWidget(id="doc_ext_" + extension[1:]) if files_extension.get(file_type)[extension]: icon_right_sample_widget.active = True # trim '.'from the file extension e.g. '.pdf', and # convert it to uppercase # so it comes 'PDF' list_item = OneLineAvatarIconListItem(text=extension[1:].upper()) list_item.add_widget(icon_right_sample_widget) dialog_content.add_widget(list_item) self.dialog = MDDialog( title="Select file extensions to include in search", content=dialog_content, size_hint=(.8, None), height=self.root.height - dp((self.root.height / 2) / 8), auto_dismiss=False) self.dialog.add_action_button("DONE", action=lambda *x: self.dialog.dismiss()) # bind the dialog to self.save_extensions method when it is closed self.dialog.bind(on_dismiss=partial(self.save_extensions, file_type)) self.dialog.open()
def _create_popup(self, instance): content = BoxLayout(orientation='vertical', spacing='5dp') list = MDList() content.add_widget(list) # add all the options uid = str(self.uid) for option, text in sorted(self.options.items(), key=lambda t: t[1]): state = 'down' if option == self.value else 'normal' # active = True if option == self.value else False btn = OneLineChekboxListItem(text=text, state=state, group=uid) btn.bind(on_release=lambda instance, option=option: self. _set_option(option)) list.add_widget(btn) self.popup = card_with_buttons( content, title=self.desc, buttons=[[_('Cancel'), self.close_dialog]])
def get_fresh_list(self): for child in self.ids.list_container.children: self.ids.list_container.remove_widget(child) sv = ScrollView() new_list = MDList() sv.add_widget(new_list) self.ids.list_container.add_widget(sv) return new_list
def __init__(self): super(lis,self).__init__() tot=network.get_firebase('Schedule') day1=tot['Day1'] day2=tot['Day2'] k1={} k2={} for no,i in enumerate(day1): if (no==0): continue k1[no]=i.replace('\\t','\t') for no,i in enumerate(day2): if (no==0): continue k2[no]=i.replace('\\t','\t') self.name='shed' t=Toolbar(title='shedule',md_bg_color= self.theme_cls.primary_color,background_palette='Primary') t.add_widget(MDRaisedButton(text='back',on_press=lambda x:self.cng_scr('vute'))) #b1=BoxLayout(orientation='vertical') b1=GridLayout(rows=12) n=MDList() l1=OneLineListItem(text='Day 1') n.add_widget(l1) k1_key=k1.keys() for i in k1_key: ln=OneLineListItem(text=k1[i]) n.add_widget(ln) l3=OneLineListItem(text='') n.add_widget(l3) l2=OneLineListItem(text='Day 2') n.add_widget(l2) k2_key=k2.keys() for i in k2_key: ln=OneLineListItem(text=k2[i]) n.add_widget(ln) b1.add_widget(t) b1.add_widget(n) self.add_widget(b1)
def __init__(self, **kwargs): super(MDListBottomSheet, self).__init__(**kwargs) self.mlist = MDList() self.gl_content.add_widget(self.mlist) Clock.schedule_once(self.resize_content_layout, 0)
def set_message_list(self): mdlist = MDList(id='mylist') scroll = self.root.ids.scroller scroll.add_widget(mdlist)