def on_enter(self): # schedules already populated if self.ids.schedule_tabs.ids.tab_manager.screens: return current_date = datetime.datetime.now().strftime('%d_%m_%Y') track_names = [] # populating schedules for i in range(*self.schedule_range): track_name = self.base_tab_name.format(i) track_names.append(track_name) track_day = str(i) tab = MDTab(id=track_day, name=track_name, text='{} Out'.format(track_day)) # tab schedule sv = ScrollView(id='tab_{}'.format(track_name), do_scroll_x=False) l = MDList() for track in self.tracks[track_day]: item = Track(info=track) l.add_widget(item) sv.add_widget(l) tab.add_widget(sv) self.ids.schedule_tabs.add_widget(tab) # not really sure if this is the way to select a tab if current_date in track_names: self.ids.schedule_tabs.current = current_date self.ids.spinner.active = False
def __init__(self, **kwargs): GridLayout.__init__(self, **kwargs) Thread.__init__(self) self.cols = 1 self.tool = ntoolbar(title='KivDL') self.add_widget(self.tool) self.body = GridLayout(cols=1, padding=(0, 20)) self.add_widget(self.body) self.tex = MDTextField(pos_hint={'center_y': 0.9}, size_hint_x=0.8) self.tex.hint_text = " Enter URL to download" self.fetch_button = MDRaisedButton(text='Fetch', pos_hint={ 'center_y': 0, 'right': 0.95 }, size_hint_x=0.1) self.fetch_button.bind(on_press=self.addcard) self.urlget = GridLayout(cols=2, size_hint_y=0.2) self.urlget.add_widget(self.tex) self.urlget.add_widget(self.fetch_button) self.body.add_widget(self.urlget) self.cardholder = ScrollView(do_scroll_x=False, size_hint_x=0.8) self.cardlist = MDList(padding=(10, 20)) self.cardlist.spacing = (10, 20) self.cardholder.add_widget(self.cardlist) self.body.add_widget(self.cardholder) self.spacer = MDLabel(size_hint_y=0.2) self.cardlist.add_widget(self.spacer)
def anime_confirmation(self, anime_list): Global.ANIME_CONFIRM_LIST = [] for anime in anime_list: Global.ANIME_CONFIRM_LIST.append(anime.name) ml = MDList() for anime in anime_list: item = OneLineRightIconListItem(text=anime.name) item.on_release = functools.partial(self.show_desc, anime) remove_button = RemoveButton(name=anime.name, icon='server-remove') item.add_widget(remove_button) ml.add_widget(item) self.dialog = MDDialog( title=str(len(anime_list)) + " Results! This is what we found for you. Click to open browser for more info!", content=ml, size_hint=(.8, None), height=dp(650), auto_dismiss=False) self.dialog.add_action_button("Cancel", action=lambda *x: self.dialog.dismiss()) self.dialog.add_action_button( "Confirm and + to watchlist", action=lambda *x: self.add_anime_to_db(self.dialog, anime_list)) self.dialog.open()
def __init__(self, screen, **kwargs): super(ContactDialog, self).__init__(**kwargs) self.screen = screen self.content = MDList() self.load_contacts() self.add_action_button(text="Cancelar", action=lambda *x: self.dismiss())
def info_dialog(self): content = MDList() label = MDLabel(font_style='Subhead', theme_text_color='Secondary', text="\n" + str(self.audio_file), valign='center', halign="center") label.bind(texture_size=label.setter('size')) image = SmartTile(allow_stretch=True, keep_ratio=True, box_color=[0, 0, 0, 0], size_hint_y=None, height=300) image._img_widget.texture = self.ids.avatar.texture content.add_widget(image) content.add_widget(label) self.dialog = MDDialog(title=self.audio_file.name, content=content, size_hint=(.8, 0.75), auto_dismiss=False) self.dialog.add_action_button("Dismiss", action=lambda *x: self.dialog.dismiss()) self.dialog.open()
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 all_student(self): self.conn = sqlite3.connect('SCHOOL.db') self.c = self.conn.cursor() self.all_students = self.c.execute('SELECT * FROM STUDENTS') gris = GridLayout( rows=2, # row_default_height=(self.width - self.cols * self.spacing[0]) / self.cols, # row_force_default=True, # size_hint_y=None, # height=self.minimum_height, padding=(dp(1), dp(1)), spacing=dp(1)) sv = ScrollView() ml = MDList() for row in self.all_students: ml.add_widget( ThreeLineListItem(text=str(row[1]), secondary_text=row[2] + '\n' + row[3])) sv.do_scroll_y = True sv.do_scroll_x = False sv.add_widget(ml) gris.add_widget( MDTextField(hint_text="Helper text on focus", helper_text="This will disappear when you click off", helper_text_mode="on_focus")) gris.add_widget(sv) self.root.ids.students.add_widget(gris) self.root.ids.screen_manager.current = str(self.root.ids.students.name)
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 bind_objects(self, productListScreen): self.productListScreen = productListScreen self.connectionManager = productListScreen.connectionManager self.productListViewModel = productListScreen.productListViewModel self.spinner = productListScreen.spinner self.scrollView = ScrollView() self.productListScreen.add_widget(widget=self.scrollView) self.mdList = MDList() self.scrollView.add_widget(widget=self.mdList)
def createmenu(self): items = ['3gp', 'mp4', 'webm', 'mkv'] self.formatbuttons = {} self.list = MDList() for x in items: self.formatbuttons[x] = MDFlatButton(text=x) self.list.add_widget(self.formatbuttons[x]) self.formatbut = dropdownmb(text='mp4') self.formatbut.bind(on_press=self.show_list) self.formatbut.pos_hint = {'center_x': 0.5, 'center_y': 0.6} self.controllay = FloatLayout() self.controllay.add_widget(self.formatbut)
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 __init__(self,**kwargs): BoxLayout.__init__(self,**kwargs) self.orientation='vertical' self.add_widget(searchbar(pos_hint={'center_x':0.5,'center_y':0.5})) self.list=MDList() self.suggestions=[] self.scroll=ScrollView(do_scroll_x=False) self.scroll.add_widget(self.list) for x in range(10): self.suggestions.append(OneLineListItem()) self.add_widget(self.scroll) self.add_widget(BoxLayout())
def list_course(self): box = BoxLayout() sv = ScrollView() ml = MDList() self.get_courses = self.c.execute('SELECT * FROM COURSES') for row in sorted(self.get_courses): ml.add_widget(OneLineListItem(text=str(row[1]))) sv.do_scroll_y = True sv.do_scroll_x = False sv.add_widget(ml) self.root.ids.courses.add_widget(sv) self.root.ids.screen_manager.current = str(self.root.ids.courses.name)
def teachers(self): sv = ScrollView() ml = MDList() rows = self.c.execute('SELECT * FROM TEACHERS') for row in sorted(rows): ml.add_widget( ThreeLineListItem(text=str(row[1]), secondary_text="id: " + str(row[0]) + '\n' 'under : ' + row[2])) sv.do_scroll_y = True sv.do_scroll_x = False sv.add_widget(ml) self.root.ids.teachers.add_widget(sv) self.root.ids.screen_manager.current = str(self.root.ids.teachers.name)
def read(self,*largs): content = FloatLayout() scroll = ScrollView() mdlist = MDList() content.add_widget(scroll) scroll.add_widget(mdlist) title = "Testimonies" pop = Popup(title= title,content= content,) pop.open() try: for message in Testify.select(): time.sleep(0.50) mdlist.add_widget(PopList(text=str(message.name),secondary_text=str(message.message))) print('reading testimonies') except peewee.OperationalError: self.login_failure('Check Network Connection')
def subjects(self): self.conn = sqlite3.connect('SCHOOL.db') self.c = self.conn.cursor() self.all_subjects = self.c.execute('SELECT * FROM STUDENTS') sv = ScrollView() ml = MDList() for row in sorted(self.all_subjects): ml.add_widget( ThreeLineListItem(text=str(row[1]), secondary_text="id: " + str(row[0]) + '\n' 'under : ' + row[2])) sv.do_scroll_y = True sv.do_scroll_x = False sv.add_widget(ml) self.root.ids.subjects.add_widget(sv) self.root.ids.screen_manager.current = str(self.root.ids.subjects.name)
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_student(self, value): sv = ScrollView() ml = MDList() sv.add_widget(ml) get_student = self.c.execute( 'SELECT * FROM STUDENTS WHERE STUDENT_CLASS_NAME = ?', (value, )) for row in get_student: ml.add_widget(OneLineListItem(text=str(row[1]))) sv.do_scroll_y = True sv.do_scroll_x = False r = GridLayout(cols=1, rows=1) r.add_widget(sv) p = Popup(title='STUDENTS', size_hint=(.7, 0.7), background_color=(0, 0, .9, .5), auto_dismiss=True) p.add_widget(r) p.open()
def load_requests(self): content = ScrollView() mdlist = MDList() content.add_widget(mdlist) title = "Prayer Requests" pop = Popup(title=title, content=content) pop.open() try: for prayer in PrayerRequest.select(): mdlist.add_widget( PopList(text=str(prayer.name), secondary_text=str(prayer.prayer_request))) except peewee.OperationalError: mdlist.add_widget( PopList( text=str('Error'), secondary_text=str( 'Please Check The Internet Connection and Try Again'))) else: pass
def __init__(self): super(lis, self).__init__() self.k1 = db.get_db('all') self.k2 = self.k1[3:] k1 = self.k1 k2 = self.k2 self.name = 'info' t = Toolbar(title='personal info', md_bg_color=self.theme_cls.primary_color, background_palette='Primary') t.add_widget( MDRaisedButton(text='back', on_press=lambda a: self.cng_scr('vute'))) #b1=BoxLayout(orientation='vertical') b1 = GridLayout(rows=12) n = MDList() l1 = OneLineListItem(text='Details') n.add_widget(l1) name = k1[0].split(' ')[0] n.add_widget(OneLineListItem(text='Name :\t' + name)) n.add_widget(OneLineListItem(text='phone :\t' + k1[1])) n.add_widget(OneLineListItem(text='email :\t' + k1[2])) l3 = OneLineListItem(text='') n.add_widget(l3) l2 = OneLineListItem(text='Registered courses') n.add_widget(l2) cou = 1 for i in range(len(k2)): if k2[i] == '1': ln = OneLineListItem(text=str(cou) + ') ' + proj[i]) cou += 1 n.add_widget(ln) if cou == 1: ln = OneLineListItem(text='no regestered courses') n.add_widget(ln) b1.add_widget(t) b1.add_widget(n) self.add_widget(b1)
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().__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)