def visualize_json(self): self.ids.friendscreen.ids.container.clear_widgets() for i in self.data.keys(): if self.data[i]['kurir'] == 'jne': image = ImageLeftWidget(source=self.kurirs[0]) if self.data[i]['kurir'] == 'tiki': image = ImageLeftWidget(source=self.kurirs[1]) if self.data[i]['kurir'] == 'pos': image = ImageLeftWidget(source=self.kurirs[2]) if self.data[i]['kurir'] == 'jnt': image = ImageLeftWidget(source=self.kurirs[8]) if self.data[i]['kurir'] == 'ninja': image = ImageLeftWidget(source=self.kurirs[7]) if self.data[i]['kurir'] == 'lion': image = ImageLeftWidget(source=self.kurirs[6]) if self.data[i]['kurir'] == 'anteraja': image = ImageLeftWidget(source=self.kurirs[3]) if self.data[i]['kurir'] == 'wahana': image = ImageLeftWidget(source=self.kurirs[5]) if self.data[i]['kurir'] == 'sicepat': image = ImageLeftWidget(source=self.kurirs[4]) isi = TwoLineAvatarListItem( text=self.data[i]['kurir'].upper(), on_press=lambda x, item=i: self.show_dialog5(text=item), secondary_text=i) isi.add_widget(image) self.ids.friendscreen.ids.container.add_widget(isi)
def on_start(self): # on_start and build methods are automatically called for i in range(20): item = TwoLineAvatarListItem(text='item ' + str(i), secondary_text='Hello World') img = ImageLeftWidget(source='itaFlag.png') item.add_widget(img) self.root.ids.container.add_widget(item)
def show_top2(self, ttl, Id): self.tlist = self.root.ids.trend_list self.root.ids.trend_toolbar.title = ttl self.tlist.clear_widgets() try: response = requests.get(playlist_details_base_url.format(Id)) if response.status_code == 200: songs_json = response.text.encode().decode() songs_json = json.loads(songs_json) self.search_data = songs_json['list'] for i in range(int(len(songs_json['list']))): #print(items['id']) #print(i) #print(songs_json['list'][i]['title']) lst = TwoLineAvatarListItem( text=songs_json['list'][i]['title'].replace( """, "'").replace("&", "&").replace("'", "'"), secondary_text=songs_json['list'][i] ['subtitle'].replace(""", "'").replace( "&", "&").replace("'", "'"), on_press=lambda x, y=i: self.song_details(y)) lst.add_widget(IconLeftWidget(icon='music-note-outline')) self.tlist.add_widget(lst) self.change_screen('TrendListScreen') except Exception as e: print(e) self.dia.dismiss()
def build_publication_button( self, img_path: str, publication: Publication) -> TwoLineAvatarListItem: button = TwoLineAvatarListItem(text=publication.title, secondary_text=publication.author, on_release=self.change_screens) button.add_widget(ImageLeftWidget(source=img_path)) return button
def load_org_list(self): self.ids['scroll'].clear_widgets() #To clear list of orgs query = f'''SELECT ORG_ID,NAME,REGISTRATION FROM ORG WHERE ORG_ID IN (SELECT ORG_ID FROM CONTACT_ORG WHERE CONTACT_ID={globalvariables.var_userid} AND MEMBER_FLAG='Y' AND STATUS='Y')''' # run direct SQL stmt = ibm_db.exec_immediate(connection.conn, query) orglist = ibm_db.fetch_both(stmt) item = TwoLineAvatarListItem() if orglist is False: self.ids['nogroupwarning'].pos_hint = {"x": 0.2, "y": 0.3} self.ids['nogroupwarning'].font_size = '20sp' self.ids[ 'nogroupwarning'].text = """You have not joined any groups. Your joined groups will show up here""" else: while (orglist): file_found = download_org_image(str(orglist[0])) if file_found == True: image = ImageLeftWidget(source="resources/org/" + str(orglist[0]) + ".png") else: image = ImageLeftWidget(source="resources/org/default.jpg") item = TwoLineAvatarListItem(text=str(orglist[1]), secondary_text=str(orglist[2])) item.add_widget(image) item.bind(on_release=self.row_press) self.ids['scroll'].add_widget(item) orglist = ibm_db.fetch_both( stmt) #for incrementing rows inside while loop
def load_group_page(self): ContentNavigationDrawer.populateNavDrawerValues(self) self.ids['allorgscroll'].clear_widgets() #To clear list of orgs query = f'''SELECT ORG_ID,NAME,REGISTRATION FROM ORG WHERE ORG_ID IN ( SELECT ORG_ID FROM ORG MINUS SELECT ORG_ID FROM CONTACT_ORG WHERE CONTACT_ID = {globalvariables.var_userid} AND STATUS='Y')''' # run direct SQL stmt = ibm_db.exec_immediate(connection.conn, query) orglist = ibm_db.fetch_both(stmt) item = TwoLineAvatarListItem() while (orglist): file_found = download_org_image(str(orglist[0])) if file_found == True: image = ImageLeftWidget(source="resources/org/" + str(orglist[0]) + ".png") else: image = ImageLeftWidget(source="resources/org/default.jpg") item = TwoLineAvatarListItem(text=str(orglist[1]), secondary_text=str(orglist[2])) item.add_widget(image) item.bind(on_release=self.row_press) self.ids['allorgscroll'].add_widget(item) orglist = ibm_db.fetch_both( stmt) #for incrementing rows inside while loop
def show_list(self, req, result): self.search_data = json.loads( result.replace(""", "'").replace("&", "&").replace("'", "'"))['songs']['data'] for i in range(len(self.search_data)): lst = TwoLineAvatarListItem( text=self.search_data[i]['title'].replace( """, "'").replace("&", "&").replace("'", "'"), secondary_text=self.search_data[i]['more_info'] ['primary_artists'].replace(""", "'").replace( "&", "&").replace("'", "'"), on_press=lambda x, y=i: self.song_details(y)) lst.add_widget(IconLeftWidget(icon='music-note-outline')) self.list_view.add_widget(lst) self.dia.dismiss()
def add_songs(self): url = 'https://spotifycharts.com/regional/in/daily/latest/download' with closing(requests.get(url, stream=True)) as r: f = (line.decode('utf-8') for line in r.iter_lines()) reader = csv.reader(f, delimiter=',', quotechar='"') for row in reader: try: pos = int(row[0]) song_name = row[1] art_name = row[2] lst = TwoLineAvatarListItem( text="{}. {}".format(pos, song_name), secondary_text=art_name, on_press=lambda x, y=song_name: self.select_spotify(y)) lst.add_widget(IconLeftWidget(icon='music-note-outline')) self.top_list.add_widget(lst) except: continue try: self.dia.dismiss() except: pass
def on_start(self): #fh = open("ingredients.txt") #ingredients = [] #for line in fh: #line = line.rstrip() #line = line.capitalize() #if line == 'Tomato': #line = 'Tomatoes' #ingredients.append(str(line)) ingredients = [ 'Eggs', 'Apple', 'Cauliflower', 'Tomatoes', 'Milk', 'Banana', 'Eggplant' ] ingredients = sorted(ingredients) MainRecipelist = {} HealthyRecipelist = {} expiry = [] for i in ingredients: if i == 'Apple': expiry.append('expiry: 3-5 days') elif i == 'Cauliflower': expiry.append('expiry: 3 days') elif i == 'Milk': expiry.append('expiry: 1 day') elif i == 'Eggs': expiry.append('expiry: 1 week') elif i == 'Banana': expiry.append('expiry: 3-5 days') elif i == 'Eggplant': expiry.append('expiry: 3 days') elif i == 'Tomatoes': expiry.append('expiry: 1 week') ingre = dict(zip(ingredients, expiry)) #====================================Main-recipelist======================================= Allrecipes = list() Alltime = [] fhandle = open('Recipes-Dataset.txt') for line in fhandle: if line[0:6] == "Recipe": y = re.findall(': (.+) R', line) Allrecipes = Allrecipes + y elif line[0:4] == "Time": z = re.findall(': (.+)', line) z = 'cooking time: ' + z[0] Alltime.append(z) Allrecipesdict = {} Allrecipesdict = dict(zip(Allrecipes, Alltime)) from itertools import zip_longest chunks = [Allrecipesdict.items()] * 7 g = (dict(filter(None, v)) for v in zip_longest(*chunks)) g = list(g) for i in ingredients: if i == "Apple": for d in (g[0:8]): MainRecipelist.update(d) elif i == "Cauliflower": for d in (g[8:16]): MainRecipelist.update(d) elif i == "Banana": for d in (g[32:40]): MainRecipelist.update(d) elif i == "Eggs": for d in (g[16:24]): MainRecipelist.update(d) elif i == "Eggplant": for d in (g[40:48]): MainRecipelist.update(d) elif i == "Tomatoes": for d in (g[48:56]): MainRecipelist.update(d) elif i == "Milk": for d in (g[24:32]): MainRecipelist.update(d) # ====================================Main-recipelist======================================= # ====================================Healthy-recipelist======================================= Allrecipes2 = list() Alltime2 = [] fhandle2 = open('Healthy-Recipes-Dataset.txt') for line in fhandle2: if line[0:6] == "Recipe": y2 = re.findall(': (.+) R', line) Allrecipes2 = Allrecipes2 + y2 elif line[0:4] == "Time": z2 = re.findall(': (.+)', line) z2 = 'cooking time: ' + z2[0] Alltime2.append(z2) Allrecipesdict2 = {} Allrecipesdict2 = dict(zip(Allrecipes2, Alltime2)) from itertools import zip_longest chunks2 = [Allrecipesdict2.items()] * 7 g2 = (dict(filter(None, v2)) for v2 in zip_longest(*chunks2)) g2 = list(g2) for i in ingredients: if i == "Apple": for d2 in (g2[0:8]): HealthyRecipelist.update(d2) elif i == "Cauliflower": for d2 in (g2[8:16]): HealthyRecipelist.update(d2) elif i == "Banana": for d2 in (g2[32:40]): HealthyRecipelist.update(d2) elif i == "Eggs": for d2 in (g2[16:24]): HealthyRecipelist.update(d2) elif i == "Eggplant": for d2 in (g2[40:48]): HealthyRecipelist.update(d2) elif i == "Tomatoes": for d2 in (g2[48:56]): HealthyRecipelist.update(d2) elif i == "Milk": for d2 in (g2[24:32]): HealthyRecipelist.update(d2) # ====================================Healthy-recipelist======================================= for k, v in ingre.items(): image = ImageLeftWidget(source='./imgs/ingredients/' + k + '.png') inl = TwoLineAvatarListItem(text=f"{k}", secondary_text=f"{v}") inl.add_widget(image) self.help_str.get_screen('ingredients').ids.container.add_widget( inl) for m, l in MainRecipelist.items(): mrimage = ImageLeftWidget(source='./imgs/recipephotos/' + m + ".jpg") recipelist = TwoLineAvatarListItem(text=f"{m}", secondary_text=f"{l}") recipelist.add_widget(mrimage) self.help_str.get_screen('recipes').ids.recipelist.add_widget( recipelist) for p, q in HealthyRecipelist.items(): hrimage = ImageLeftWidget(source='./imgs/healthyrecipephotos/' + p + ".jpg") healthyrecipelist = TwoLineAvatarListItem(text=f"{p}", secondary_text=f"{q}") healthyrecipelist.add_widget(hrimage) self.help_str.get_screen( 'healthyrecipes').ids.healthyrecipelist.add_widget( healthyrecipelist)