def __init__(self, **kwargs): super(ListScrollApp, self).__init__(**kwargs) self.Main_Win = MDFloatLayout() self.Rel_Win = RelativeLayout() self.List_Scr = ScrollView() self.The_List = MDList() return
def no_sessions_grid(self, msg, layout): new_card_layout = MDFloatLayout() # for centering excCard = MDCard( spacing=15, radius=[80], orientation="vertical", size_hint=(0.87, 0.7), padding=[ 11, 16, 0, 25 ], # [padding_left, padding_top,padding_right, padding_bottom]. pos_hint={ "center_y": 0.5, "center_x": 0.5 }, background="resources/card_back.png", elevation=1) workout_name = MDLabel(text=msg, halign='center', font_style="Subtitle2", size_hint=(1, 0.1), theme_text_color="Custom", text_color=self.app.text_color) excCard.add_widget(workout_name) new_card_layout.add_widget(excCard) try: if self.ids.sets_grid == layout: dict_of_row_height = {0: 250} layout.rows_minimum = dict_of_row_height except: pass layout.clear_widgets() layout.add_widget(new_card_layout)
def __init__(self, **kwargs): super(LayoutsApp, self).__init__(**kwargs) self.NDrawer = MDNavigationDrawer() self.Screen1 = MDFloatLayout() self.BLay = BoxLayout() self.MDTool = MDToolbar() self.Widgy = Widget() self.NLayout = NavigationLayout() self.CNDrawer = ContentNavigationDrawer() return
class ListScrollApp(MDApp): def __init__(self, **kwargs): super(ListScrollApp, self).__init__(**kwargs) self.Main_Win = MDFloatLayout() self.Rel_Win = RelativeLayout() self.List_Scr = ScrollView() self.The_List = MDList() return def build(self): ####################################### self.Main_Win.size = Window.size Xc = int(self.Main_Win.width * 0.5) Yc = int(self.Main_Win.height * 0.5) ####################################### self.Rel_Win.size_hint = (None, None) self.Rel_Win.width = int(self.Main_Win.width * 0.3) self.Rel_Win.height = int(self.Main_Win.height * 0.5) self.Rel_Win.x = Xc - int(self.Rel_Win.width * 0.5) self.Rel_Win.y = Yc - int(self.Rel_Win.height * 0.5) ####################################### self.List_Scr.bar_inactive_color = (0.4, 0, 0, 1) self.List_Scr.bar_color = (1, 0.15, 0.15, 1) self.List_Scr.bar_margin = 5 self.List_Scr.bar_width = int(self.Rel_Win.width * 0.10) self.List_Scr.bar_pos_y = 'right' # self.List_Scr.scroll_type = ['content'] # self.List_Scr.scroll_type = ['bars'] self.List_Scr.scroll_type = ['content', 'bars'] ####################################### Height1 = int(self.Rel_Win.height / 10) self.The_List.clear_widgets() for i in range(100): self.The_List.add_widget(Button(text=f"Button Number {i}", \ size_hint = (None, None), \ width = self.Rel_Win.width, \ height = Height1)) ####################################### if(self.The_List.parent == None): self.List_Scr.add_widget(self.The_List) if(self.List_Scr.parent == None): self.Rel_Win.add_widget(self.List_Scr) if(self.Rel_Win.parent == None): self.Main_Win.add_widget(self.Rel_Win) ####################################### self.List_Scr.scroll_x = 1 self.List_Scr.scroll_y = 1 ####################################### return self.Main_Win
class LayoutsApp(MDApp): ################################### def __init__(self, **kwargs): super(LayoutsApp, self).__init__(**kwargs) self.NDrawer = MDNavigationDrawer() self.Screen1 = MDFloatLayout() self.BLay = BoxLayout() self.MDTool = MDToolbar() self.Widgy = Widget() self.NLayout = NavigationLayout() self.CNDrawer = ContentNavigationDrawer() return ################################### def My_Callback(self, instance): self.NDrawer.set_state('toggle') return ################################### def build(self): ############################### self.Screen1.size = Window.size self.NLayout.size = self.Screen1.size self.NLayout._scrim_color = Color( rgba=[0, 0, 0, 0]) # Necessary to avoid Exception self.BLay.size = self.Screen1.size self.BLay.orientation = 'vertical' self.MDTool.title = 'Navigation Drawer' self.MDTool.elevation = 10 self.MDTool.left_action_items = [['menu', self.My_Callback]] ############################### if (self.MDTool.parent == None): self.BLay.add_widget(self.MDTool) if (self.Widgy.parent == None): self.BLay.add_widget(self.Widgy) if (self.BLay.parent == None): self.Screen1.add_widget(self.BLay) if (self.CNDrawer.parent == None): self.NDrawer.add_widget(self.CNDrawer) if (self.NDrawer.parent == None): self.NLayout.add_widget(self.NDrawer) if (self.NLayout.parent == None): self.Screen1.add_widget(self.NLayout) ############################### LayoutsApp.title = 'Navigation Drawer' self.CNDrawer.Initialize() return self.Screen1
def __init__(self, **kwargs): super().__init__(**kwargs) self.orientation = 'vertical' # Main screen layout screen_layout = MDGridLayout() screen_layout.cols = 2 screen_layout.md_bg_color = [0, 1, 1, 1] # AC region self.timer = 0 # AC Card new_layout = MDFloatLayout() self.ac_card1 = AcCard((0.75, 0.75)) self.ac_card1.on_press = self.ac_touch_down self.ac_card1.on_release = self.ac_touch_up new_layout.add_widget(self.ac_card1) screen_layout.add_widget(new_layout) self.content = AcPopup() self.content.ac_card.on_release = partial(self.ac_touch_up, popup=True) self.ac_popup = Popup(title='AC settings', size_hint=(.75, .75)) self.ac_popup.content = self.content self.ac_popup.background_color = [i / 255 for i in [137, 205, 211]] + [1] #--------------------------------------------------------------# # Light setup new_layout = MDFloatLayout() self.light_card = MDCard( orientation='horizontal', padding='10dp', pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }, size_hint=(0.75, 0.75), ) self.light_card.md_bg_color = app.dark_color light_image = Image( source='static/light1.png', size_hint=(1, 1), ) self.light_card.on_press = self.light_change self.light_card.add_widget(light_image) new_layout.add_widget(self.light_card) screen_layout.add_widget(new_layout) screen_layout.add_widget(Button(text='TODO')) screen_layout.add_widget(Button(text='TODO')) screen_layout.add_widget(Button(text='TODO')) screen_layout.add_widget(Button(text='TODO')) screen_layout.add_widget(Button(text='TODO')) screen_layout.add_widget(Button(text='TODO')) self.add_widget(screen_layout)
def start_downloading(self): user_input = self.root.get_screen('main').ids.url_input.text # video = YouTube(user_input) # print(type(video)) if user_input != '' and re.search(r'^(https?\:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/.+$', user_input): self.root.current = 'progress' screen_id = self.root.get_screen('progress').ids.video_list for num in range(1): main_layout = MDFloatLayout() flip_card = MDCard(size_hint=(.9, .9), pos_hint={'center_x':.5, 'center_y': .5}) box_1 = MDBoxLayout(orientation='vertical',) box_2 = MDBoxLayout(orientation='vertical', ) box_3 = MDBoxLayout(orientation='vertical', padding=20) img = AsyncImage(source=video.thumbnail_url, size_hint=(.9, .9), pos_hint={'center_x': .5, 'center_y': .5}) box_3.add_widget(img) box_3.add_widget( MDLabel( text=video.title, halign='center', font_style='Body2' ) ) box_2.add_widget(box_3) box_2.add_widget(MDRaisedButton(text='Download', pos_hint={'center_x': .5, 'center_y': .5}, size_hint=(.6, .1), on_release = self.quality_check,)) box_1.add_widget(box_2) advertisement_box = MDBoxLayout(orientation='vertical', size_hint=(1, .2)) advertisement_box.add_widget(MDLabel(text='Advertisement', halign='center')) advertisement_box.add_widget(MDProgressBar(pos_hint={"center_x": .5, })) box_1.add_widget(advertisement_box) flip_card.add_widget(box_1) main_layout.add_widget(flip_card) screen_id.add_widget(main_layout) else: self.show_message('Invalid URL!')
def __init__(self, **kwargs): super(ItemList, self).__init__() #need left float layout left = MDFloatLayout() left_list = ThreeLineAvatarListItem( text=kwargs['name'], secondary_text='Expiration Date: ' + kwargs['exp_date'], tertiary_text='Extra Notes: ' + kwargs['extra_notes'] + ', Quantity: ' + kwargs['quantity'], pos_hint={"top": .5}) left_image = Image(source='icons/foodbag.png', pos_hint={ "top": .95, "center_x": .08 }, size_hint=(.7, .7)) left_list.add_widget(left_image) left.add_widget(left_list) self.add_widget(left)
def build(self): # AC Card self.ac_card = AcCard((0.5, 0.5)) self.add_widget(self.ac_card) # all the features for ac features_layout = MDGridLayout() features_layout.cols = 2 # Temp incease, decrease new_box_layout = MDFloatLayout() dec_button = Buttonn('temp-', colors['cold_color']) new_box_layout.add_widget(dec_button) dec_button.on_press = partial(self.ac_features_send, dec_button) features_layout.add_widget(new_box_layout) new_box_layout = MDFloatLayout() inc_button = MDCard( orientation='vertical', padding='10dp', pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }, size_hint=(0.75, 0.75), ) inc_button.md_bg_color = ['warm_color'] inc_button.add_widget(MDLabel(text='Temp+')) inc_button.id = 'temp+' inc_button.on_press = partial(self.ac_features_send, inc_button) new_box_layout.add_widget(inc_button) features_layout.add_widget(new_box_layout) features_layout.add_widget(btn(text='TODO')) features_layout.add_widget(btn(text='TODO')) features_layout.add_widget(btn(text='TODO')) features_layout.add_widget(btn(text='TODO')) self.add_widget(features_layout)
def create_exc_card(self, exc, num_of_exc, num_of_exc_total): card_layout = MDFloatLayout() # for centering excCard = MDCard( spacing=2, radius=[80], orientation="vertical", size_hint=(0.95, 0.8), padding=[ 20, 0, 0, 20 ], # [padding_left, padding_top,padding_right, padding_bottom]. pos_hint={ "center_y": 0.5, "center_x": 0.5 }, background="resources/card_back.png") help_layout = MDGridLayout(rows=1, cols=2, size_hint_y=0.4) excnum = str(num_of_exc + 1) + " of " + str(num_of_exc_total) exc_num = MDLabel( text=excnum, font_style="Caption", theme_text_color="Secondary", ) del_Button = MDIconButton( icon="trash-can-outline", theme_text_color="Custom", text_color=self.app.text_color, on_release=self.show_del_exercise_dialog, ) self.del_button_id_by_exc[exc] = del_Button self.exc_by_del_button[del_Button] = exc help_layout.add_widget(exc_num) help_layout.add_widget(del_Button) excCard.add_widget(help_layout) name_layout = MDGridLayout(rows=1, cols=2, padding=[ 0, 10, 0, 25 ]) # [padding_left, padding_top,padding_right, padding_bottom]) exc_name = MDLabel(text=exc, font_style="H5", theme_text_color="Custom", text_color=self.app.text_color) # consider hiding option sButton = MDIconButton( icon="history", theme_text_color="Custom", text_color=self.app.theme_cls.primary_color, on_release=self.show_exc_history, ) self.stats_button_id_by_exc[exc] = sButton self.exc_by_stats_button[sButton] = exc name_layout.add_widget(exc_name) name_layout.add_widget(sButton) excCard.add_widget(name_layout) card_layout.add_widget(excCard) return card_layout
def load_bookmarked(self): """ This function reads the json's stored in /bookmarks. It then proceeds to initialize the widgets for each listing It adds all the widget to the boxlayout. Finally, it checks which listing has the lowest price/highest rating and add tags accordingly. The lowest price cannot be 0 and the best rated listing must have at least 10 ratings. """ best_price_box = {} best_rating_box = {} web_button_data = {} location_data = {} path = 'bookmarks' full_path = os.path.join(os.getcwd(), path) for filenames in os.walk(full_path): for filename in filenames[2]: current_file = open(os.path.join(full_path, filename), "r") data = json.load(current_file) main_box_per_listing = MDBoxLayout(size_hint_y=None, height="240dp", orientation="horizontal", padding=[dp(4), dp(4)], spacing=dp(4)) image_box = MDFloatLayout(size_hint=[0.4, 1]) text_box = MDBoxLayout(orientation='horizontal') super_vertical_box = MDBoxLayout(orientation='vertical', ) super_horizontal_box = MDBoxLayout(orientation='horizontal', padding=dp(10)) vertical_box_tile_and_room_type = MDBoxLayout( orientation='vertical', size_hint_y=0.7) vertical_box_room_type = MDBoxLayout(size_hint_y=0.3) vertical_box_title = MDBoxLayout(size_hint_y=0.7) vertical_box_buttons = MDFloatLayout(size_hint_x=0.1) vertical_box_nr_of_guests = MDBoxLayout( orientation='horizontal') horizontal_box_rating = MDBoxLayout(orientation='horizontal') horizontal_box_star = MDBoxLayout(orientation='horizontal', size_hint_x=0.3) img = AsyncImage(source=data['picture_url'], allow_stretch=True, keep_ratio=False, pos_hint={ 'center_x': .5, 'center_y': .5 }, size_hint_y=1, width=100) roomtype_label = MDLabel( text= f"[color=808080]{data['room_type']} in {data['village']}" f" ({data['borough']})[/color]", markup=True, halign='left', pos_hint={ 'center_x': .5, 'center_y': .75 }) title_label = MDLabel(text=f"[size=25]{data['name']}[/size]", markup=True, halign='left', pos_hint={ 'center_x': .5, 'center_y': .85 }) """ reviews_expansion = MDExpansionPanel( icon="", # panel icon content=ContentReviews(), # panel content panel_cls=MDExpansionPanelOneLine(text="Reviews"), # panel class ) """ if data['guests_included'] == 1: guest_text = f"{data['guests_included']} guest · {data['minimum_nights']} minimum nights · " \ f"{data['maximum_nights']} maximum nights" else: guest_text = f"{data['guests_included']} guests · {data['minimum_nights']} minimum nights · " \ f"{data['maximum_nights']} maximum nights" guests_included_label = MDLabel(text=guest_text, halign='left', pos_hint={ 'center_x': .5, 'center_y': .35 }) price_label = MDLabel( text=f"[size=35][b]{data['price']}$[/b]/night[/size]", markup=True, halign='right', pos_hint={ 'center_x': 0.3, 'center_y': .1 }) line = MDSeparator(height=dp(1)) if not data['price'] == 0: best_price_box[image_box] = data['price'] if data['number_of_reviews'] >= 10: best_rating_box[image_box] = float( data['review_score']) / 20 superhost_chip = MDChip( text='SUPERHOST', pos_hint={ 'center_x': .20, 'center_y': .90 }, icon='', color=[1, 1, 1, 1], ) staricon = MDIcon(icon='star', pos_hint={ 'left_x': .50, 'center_y': .08 }) starlabel = MDLabel( text= f"[b]{float(data['review_score']) / 20}[/b] ({data['number_of_reviews']})", markup=True, pos_hint={ 'left_x': .50, 'center_y': .07 }) webbutton = WebButton(icon='search-web', user_font_size="36sp", pos_hint={ 'center_x': .9, 'center_y': .3 }, url_dictionary=web_button_data) web_button_data[webbutton] = data['listing_url'] bookmarkbutton = ListingSaveButton(data, pos_hint={ 'center_x': .9, 'center_y': .7 }, opposite_colors=False, icon='delete') loc_button = LocationButton(icon='map-outline', pos_hint={ 'center_x': .9, 'center_y': .5 }, location_dictionary=location_data, listing_id=data['id']) location_data[loc_button] = [ float(data['latitude']), float(data['longitude']) ] # ADD WIDGETS image_box.add_widget(img) if data['is_superhost']: image_box.add_widget(superhost_chip) vertical_box_title.add_widget(title_label) vertical_box_room_type.add_widget(roomtype_label) vertical_box_tile_and_room_type.add_widget( vertical_box_room_type) vertical_box_tile_and_room_type.add_widget(vertical_box_title) vertical_box_buttons.add_widget(bookmarkbutton) vertical_box_buttons.add_widget(loc_button) vertical_box_buttons.add_widget(webbutton) horizontal_box_star.add_widget(staricon) horizontal_box_star.add_widget(starlabel) horizontal_box_rating.add_widget(horizontal_box_star) horizontal_box_rating.add_widget(price_label) super_horizontal_box.add_widget(horizontal_box_rating) vertical_box_nr_of_guests.add_widget(guests_included_label) #vertical_box_nr_of_guests.add_widget(reviews_expansion) super_vertical_box.add_widget(vertical_box_tile_and_room_type) super_vertical_box.add_widget(vertical_box_nr_of_guests) super_vertical_box.add_widget(super_horizontal_box) text_box.add_widget(super_vertical_box) text_box.add_widget(vertical_box_buttons) main_box_per_listing.add_widget(image_box) main_box_per_listing.add_widget(text_box) self.ids.comparebox.add_widget(main_box_per_listing) self.ids.comparebox.add_widget(line) best_price_chip = MDChip(text='BEST PRICE', pos_hint={ 'center_x': .8, 'center_y': .9 }, icon='', text_color=[1, 1, 1, 1], color=[0.01, 0.28, 0.99, 1], spacing=dp(4)) #if no listing is bookmarked then return print(len(self.ids.comparebox.children)) if (len(self.ids.comparebox.children) == 0): empty_label = MDLabel( text= "No listing on Wishlist.\nPlease add some listings on the Map screen", pos_hint={ "center_x": 0.9, "center_y": 4 }) self.ids.comparebox.height = self.height self.ids.comparebox.add_widget(empty_label) elif (len(self.ids.comparebox.children) <= 2): return else: min(best_price_box, key=best_price_box.get).add_widget(best_price_chip) if min(best_price_box, key=best_price_box.get) == max(best_rating_box, key=best_rating_box.get): pos = {'center_x': .8, 'center_y': 0.77} else: pos = {'center_x': .8, 'center_y': .9} best_rating_chip = MDChip(text='BEST RATING', pos_hint=pos, icon='', color=[0.98, 0.92, 0.01, 1], spacing=dp(4)) # needs 10 ratings if len(best_rating_box) is not 0: max(best_rating_box, key=best_rating_box.get).add_widget(best_rating_chip)
def create_weight_card(self, weight, weight_date): new_card_layout = MDFloatLayout() # for centering help_layout = MDGridLayout(size_hint_y=0.05, rows=1, cols=3) excCard = LongPressCard( spacing=8, radius=[80, 0, 80, 0], orientation="horizontal", size_hint=(0.95, 0.97), padding=[40, 40, 20, 40], # [padding_left, padding_top,padding_right, padding_bottom]. pos_hint={"center_y": 0.5, "center_x": 0.5}, background="resources/card_back_prev.png", elevation=1, long_press_time=0.5, on_long_press=lambda w: setattr(w, 'text', 'long press!') ) excCard.card_id = excCard # help_layout = self.create_top_card_layout(num_of_exc, num_of_exc_total, exc) # excCard.add_widget(help_layout) label_weight_date = weight_date.ctime()[0:10] label_weight_date = label_weight_date[8:] + "\n" + label_weight_date[4:7] weight, unit = self.app.fix_weight_by_unit(weight) date_label = MDLabel( text=label_weight_date, font_style="H6", size_hint=(0.2, 1), theme_text_color="Custom", text_color=(1, 1, 1, 1) ) excCard.add_widget(date_label) main_layout = MDGridLayout(rows=1, cols=2, spacing=20) deleteBox = MDCheckbox( size_hint=(0.5, 0.75), on_release=self.update_del_num ) deleteBox.opacity = 0 self.session_card_by_checkBox[deleteBox] = excCard weight_label = MDLabel( text=str(weight) + " " + unit, font_style="H5", theme_text_color="Custom", text_color=self.app.text_color, size_hint=(1.4, 1.6), halign='center' ) main_layout.add_widget(weight_label) main_layout.add_widget(deleteBox) # main_layout.add_widget(MDFillRoundFlatButton( # text="Load", # text_color=(1, 1, 1, 1), # size_hint_y=0.1, # on_release=self.load_for_running_session)) excCard.add_widget(main_layout) new_card_layout.add_widget(excCard) self.session_key_by_card[excCard] = weight_date return new_card_layout
def __init__(self, **kwargs): super().__init__(**kwargs) self.orientation = 'vertical' # Main screen layout screen_layout = MDGridLayout() screen_layout.cols = 2 screen_layout.md_bg_color = [0, 1, 1, 1] # AC region self.timer = 0 new_layout = MDFloatLayout() self.new_card = MDCard( orientation='vertical', padding='10dp', pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }, size_hint=(0.75, 0.75), ) self.new_card.md_bg_color = app.off_red ac_image = Image(source='static/ac1.png', ) ac_image.size_hint_y = 0.9 ac_image.pos_hint = {'top': 1.0, 'center_x': 0.5} self.new_card.radius = [4] * 4 # ac_button.bind(active=callback) self.new_card.add_widget(ac_image) self.new_card.on_press = self.ac_touch_down self.new_card.on_release = self.ac_touch_up temp = MDLabel(text='18ºC') temp.font_size = 10 temp.size = (0.25, 1) temp.color = [1, 1, 1, 1] new_layout.add_widget(self.new_card) screen_layout.add_widget(new_layout) self.ac_popup = Popup(title='AC settings', content=AcFeatures(), size_hint=(0.75, 0.75)) self.ac_popup.background_color = [i / 255 for i in [137, 205, 211]] + [1] #self.ac_popup.on_open = self.faltu #--------------------------------------------------------------# # Light setup new_layout = MDFloatLayout() self.light_card = MDCard( orientation='horizontal', padding='10dp', pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }, size_hint=(0.75, 0.75), ) self.light_card.md_bg_color = app.dark_color light_image = Image( source='static/light1.png', size_hint=(1, 1), ) self.light_card.on_press = self.light_change self.light_card.add_widget(light_image) new_layout.add_widget(self.light_card) screen_layout.add_widget(new_layout) screen_layout.add_widget(Button(text='TODO')) screen_layout.add_widget(Button(text='TODO')) screen_layout.add_widget(Button(text='TODO')) screen_layout.add_widget(Button(text='TODO')) screen_layout.add_widget(Button(text='TODO')) screen_layout.add_widget(Button(text='TODO')) self.add_widget(screen_layout)
def resultsCarousel(self, *args): with open('results/' + args[0] + '.mock', 'r') as f: line = f.readline() qo = f.readlines() name, id, date, qn, t = line.split(',') with open('results/' + id + ".ans", 'r') as a: answers = a.readline().split(',') cq = 0 wq = 0 for i in range(int(qn)): ewai = qo[i].split(',') if ewai[1] == answers[i]: cq += 1 else: wq += 1 sm = self.root.ids['result'].ids['result_view'] sm.current = 'view' self.root.ids['result'].ids['testName'].text = name self.root.ids['result'].ids['testID'].text = id self.root.ids['result'].ids['date'].text = date self.root.ids['result'].ids['AQ'].text = qn self.root.ids['result'].ids['CQ'].text = str(cq) self.root.ids['result'].ids['WQ'].text = str(wq) for i in range(int(qn)): ewai = qo[i].split(',') fl = MDFloatLayout() card = MDCard(pos_hint={ 'center_x': .5, 'center_y': .5 }, size_hint=(.9, .58), elevation=11) lb = MDLabel(text=ewai[0], halign='center', font_style='H6') gl = MDGridLayout(cols=2) gl1 = MDGridLayout(cols=1, md_bg_color=[0, 1, 0, 1] if answers[i] == ewai[1] else [1, 0, 0, 1]) lb1 = MDLabel(text="A:- " + ewai[1], halign='center') lb2 = MDLabel(text="B:- " + ewai[2], halign='center') lb3 = MDLabel(text="C:- " + ewai[3], halign='center') lb4 = MDLabel(text="D:- " + ewai[4], halign='center') lb5 = MDLabel(text="Your Option:- " + answers[i], halign='center') bl = MDBoxLayout(orientation='vertical') fl.add_widget(card) card.add_widget(bl) bl.add_widget(lb) bl.add_widget(gl) gl.add_widget(lb1) gl.add_widget(lb2) gl.add_widget(lb3) gl.add_widget(lb4) bl.add_widget(gl1) gl1.add_widget(lb5) self.root.ids['result'].ids['carousel'].add_widget(fl)
def add_set_to_grid(self, currReps, currWeight): rep_inc = 0 weight_inc = 0 if currReps > 9: rep_inc = -0.015 self.sets.append([currReps, currWeight]) currWeight, unit = self.app.fix_weight_by_unit(currWeight) if len(str(currWeight)) > 3: weight_inc = -0.004 * len(str(currWeight)) num_of_set = len(self.sets) # self.ids["md_list"].add_widget( # SwipeToDeleteItem(text=f"{currReps} X {currWeight}", size_hint=(1, 1)) # ) set_add = 0.05 x_add = 0.23 set_layout = MDFloatLayout() set_num = "SET " + str(num_of_set) + ":" set_layout.add_widget( MDLabel(text=set_num, size_hint=(1, 0.2), font_style="H5", pos_hint={ "center_y": 0.7, "center_x": 0.62 + set_add }, theme_text_color="Custom", text_color=self.app.text_color)) set_layout.add_widget( MDLabel(text=str(currReps), size_hint=(1, 0.2), font_style="H5", pos_hint={ "center_y": 0.7, "center_x": 0.865 + x_add + rep_inc }, theme_text_color="Custom", text_color=self.app.text_color)) set_layout.add_widget( MDLabel(text="X", size_hint=(1, 0.2), font_style="H5", pos_hint={ "center_y": 0.7, "center_x": 0.969 + x_add }, theme_text_color="Custom", text_color=self.app.text_color)) set_layout.add_widget( MDLabel(text=str(currWeight), size_hint=(1, 0.2), font_style="H5", pos_hint={ "center_y": 0.7, "center_x": 1.06 + x_add + weight_inc }, theme_text_color="Custom", text_color=self.app.text_color)) set_layout.add_widget( MDLabel(text=f"Reps", font_style="Caption", pos_hint={ "center_y": 0.3, "center_x": 0.86 + x_add }, theme_text_color="Secondary")) last_label = MDLabel(text=unit, font_style="Caption", pos_hint={ "center_y": 0.3, "center_x": 1.09 + x_add }, theme_text_color="Secondary") set_layout.add_widget(last_label) self.ids["sets_grid"].add_widget(set_layout) if len(self.sets) > 5: self.ids.sets_scroll.scroll_to(last_label, padding=10, animate=True)
def create_card(self, num_of_exc, exc, num_of_exc_total): if self.view_mode: session_rec = self.session_rec_to_view else: session_rec = self.session_rec newlayout = MDFloatLayout() # for centering if exc in session_rec: set_amount = len(session_rec[exc]) else: set_amount = 0 # card_y_size = 200 # card_y_size = str(card_y_size + set_amount * 50) + "dp" self.ids.exc_cards.row_default_height += set_amount * 175 if not self.view_mode: excCard = MDCard_Custom( spacing=5, radius=[80], orientation="vertical", size_hint=(0.9, 0.85), padding=[ 25, 25, 0, 20 ], # [padding_left, padding_top,padding_right, padding_bottom]. pos_hint={ "center_y": 0.5, "center_x": 0.5 }, background="resources/card_back.png", on_release=self.active_card_check_box, elevation=1, ) else: excCard = MDCard( spacing=5, radius=[80], orientation="vertical", size_hint=(0.9, 0.85), padding=[ 25, 25, 0, 45 ], # [padding_left, padding_top,padding_right, padding_bottom]. pos_hint={ "center_y": 0.5, "center_x": 0.5 }, background="resources/card_back.png", elevation=1, ) help_layout, check_box = self.create_top_card_layout( num_of_exc, num_of_exc_total, exc) self.check_box_by_card[excCard] = check_box excCard.add_widget(help_layout) name_layout_y_size = 2.5 if self.view_mode: name_layout_y_size = 2 name_layout = MDGridLayout(size_hint_y=name_layout_y_size, rows=1, cols=1) exc_name = MDLabel(text=exc, font_style="H5", theme_text_color="Custom", text_color=self.app.text_color) name_layout.add_widget(exc_name) excCard.add_widget(name_layout) # session = ["3 X 8", "3 X 8", "3 X 8", "3 X 8"] session = [] if exc in session_rec: session = session_rec[exc] for num_of_set, set in enumerate(session): exc_layout = MDGridLayout(rows=1, cols=2) units_layout = MDGridLayout(rows=1, cols=2) if self.view_mode: exc_layout = MDGridLayout(rows=1, cols=2) units_layout = MDGridLayout(rows=1, cols=2) set_label, set_number, reps_label = self.create_set_label( set, num_of_set) exc_layout.add_widget(set_label) exc_layout.add_widget(set_number) units_layout.add_widget(MDLabel(text="", size_hint_x=0.9)) units_layout.add_widget(reps_label) excCard.add_widget(exc_layout) excCard.add_widget(units_layout) # new_exc_layout, new_units_layout = self.create_set_label(set, num_of_set) # excCard.add_widget(new_exc_layout) # excCard.add_widget(new_units_layout) if not self.view_mode: button_layout = self.create_button_layout(exc) excCard.add_widget(button_layout) # For fast deletion self.ex_reference_by_exc[exc] = excCard newlayout.add_widget(excCard) return newlayout
def create_card(self, session, num_of_session, total_session_num, session_workout_name, session_date): new_card_layout = MDFloatLayout() # for centering excCard = MDCard( spacing=5, radius=[80], orientation="vertical", size_hint=(0.87, 0.97), padding=[ 25, 16, 15, 25 ], # [padding_left, padding_top,padding_right, padding_bottom]. pos_hint={ "center_y": 0.5, "center_x": 0.5 }, background="resources/card_back.png", elevation=1) # help_layout = self.create_top_card_layout(num_of_exc, num_of_exc_total, exc) # excCard.add_widget(help_layout) excnum = str(num_of_session + 1) + " of " + str(total_session_num) exc_num = MDLabel(text=" " + excnum, font_style="Caption", theme_text_color="Secondary", pos_hint={ "center_y": 0.85, "center_x": 0.17 }) # help_layout.add_widget(exc_num) # excCard.add_widget(help_layout) name_layout_y_size = 1.5 if len(session_workout_name) > 9: name_layout_y_size = 3 name_layout = MDGridLayout(rows=1, cols=3, size_hint_y=name_layout_y_size) workout = session_workout_name workout_name = MDLabel(text=workout, font_style="H5", theme_text_color="Custom", text_color=self.app.text_color, size_hint_x=1.5) workout_date = MDLabel(text=str(session_date), font_style="Caption", theme_text_color="Custom", text_color=self.app.text_color) name_layout.add_widget(workout_name) name_layout.add_widget(workout_date) name_layout.add_widget(exc_num) excCard.add_widget(name_layout) seperate = MDSeparator(height="1dp", color=self.app.text_color) excCard.add_widget(seperate) # session = ["3 X 8", "3 X 8", "3 X 8", "3 X 8"] for num_of_set, set in enumerate(session): set_label, set_number, reps_label = self.create_set_label( set, num_of_set) exc_layout = MDGridLayout(rows=1, cols=2) units_layout = MDGridLayout(rows=1, cols=2, size_hint_y=1.5) exc_layout.add_widget(set_label) exc_layout.add_widget(set_number) units_layout.add_widget(MDLabel(text="", size_hint_x=0.9)) units_layout.add_widget(reps_label) excCard.add_widget(exc_layout) excCard.add_widget(units_layout) new_card_layout.add_widget(excCard) return new_card_layout
def create_card(self, session_workout_name, session_date, session_duration, sessions_date_key, num_exc_completed): new_card_layout = MDFloatLayout() # for centering if self.app.reload_for_running_session: excCard = MDCard( spacing=8, radius=[80, 0, 80, 0], orientation="horizontal", size_hint=(0.95, 0.97), padding=[40, 40, 20, 40], # [padding_left, padding_top,padding_right, padding_bottom]. pos_hint={"center_y": 0.5, "center_x": 0.5}, background="resources/card_back_prev.png", elevation=1, on_release=self.view_session, ) else: excCard = LongPressCard( spacing=8, radius=[80, 0, 80, 0], orientation="horizontal", size_hint=(0.95, 0.97), padding=[40, 40, 20, 40], # [padding_left, padding_top,padding_right, padding_bottom]. pos_hint={"center_y": 0.5, "center_x": 0.5}, background="resources/card_back_prev.png", elevation=1, long_press_time=0.5, on_long_press=lambda w: setattr(w, 'text', 'long press!') ) excCard.card_id = excCard # help_layout = self.create_top_card_layout(num_of_exc, num_of_exc_total, exc) # excCard.add_widget(help_layout) session_date = session_date.ctime()[0:10] session_date = " " + session_date[8:] + "\n " + session_date[4:7] print(session_date) date_size_hint_x = 0.2 if self.app.reload_for_running_session: date_size_hint_x = 0.25 date_label = MDLabel( text=session_date, font_style="H6", size_hint=(date_size_hint_x, 1), theme_text_color="Custom", text_color=(1, 1, 1, 1) ) excCard.add_widget(date_label) main_layout = MDGridLayout(rows=2, cols=2, spacing=20) deleteBox = MDCheckbox( size_hint=(0.5, 0.75), on_release=self.update_del_num ) deleteBox.opacity = 0 self.session_card_by_checkBox[deleteBox] = excCard workout_name_label = MDLabel( text=session_workout_name, font_style="H5", theme_text_color="Custom", text_color=self.app.text_color, size_hint=(1.6, 1.6) ) workout_completed_label = MDLabel( text=str(num_exc_completed) + " Exercises Completed", font_style="Caption", size_hint=(0.8, 0.4), theme_text_color="Secondary" ) workout_duration_label = MDLabel( text=" " + session_duration, font_style="Caption", size_hint=(0.6, 0.1), theme_text_color="Secondary" ) main_layout.add_widget(workout_name_label) main_layout.add_widget(deleteBox) # main_layout.add_widget(workout_duration_label) main_layout.add_widget(workout_completed_label) # if self.app.reload_for_running_session: # main_layout.add_widget(MDLabel( # text="", # size_hint=(0.1,0.1))) # # main_layout.add_widget(MDFillRoundFlatButton( # text="LOAD", # text_color=(1, 1, 1, 1), # size_hint=(0.3,1.5), # on_release=self.load_for_running_session)) excCard.add_widget(main_layout) if self.app.reload_for_running_session: excCard.add_widget(MDFillRoundFlatButton( text="LOAD", text_color=(1, 1, 1, 1), on_release=self.load_for_running_session)) new_card_layout.add_widget(excCard) self.session_key_by_card[excCard] = sessions_date_key return new_card_layout