Beispiel #1
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        if self.size_hint == [1, 1] and DEVICE_TYPE == "mobile":
            self.size_hint = (None, None)
            self.width = dp(280)
        elif self.size_hint == [1, 1] and DEVICE_TYPE == "desktop":
            self.size_hint = (None, None)
            self.width = dp(560)

        if not self.title:
            self._spacer_top = 0

        if not self.buttons:
            self.ids.root_button_box.height = 0
        else:
            self.create_buttons()

        if self.type in ("simple", "confirmation"):
            if self.type == "confirmation":
                self.ids.spacer_top_box.add_widget(MDSeparator())
                self.ids.spacer_bottom_box.add_widget(MDSeparator())
            self.create_items()
        if self.type == "custom":
            if self.content_cls:
                self.ids.container.remove_widget(self.ids.scroll)
                self.ids.container.remove_widget(self.ids.text)
                self.ids.spacer_top_box.add_widget(self.content_cls)
                self._spacer_top = self.content_cls.height + dp(24)
                self.ids.spacer_top_box.padding = (0, "24dp", "16dp", 0)
        if self.type == "alert":
            self.ids.scroll.bar_width = 0
 def fetchData(self, tab):
     tab.clear_widgets()
     cur.execute("SELECT id,name,due,amount FROM RECORDS")
     rows = cur.fetchall()
     rows.insert(0, ["Inv No", "Name", "Due Date", "Amount"])
     temp = ScrollView()
     root1 = StackLayout(size_hint_y=None, spacing=0, orientation="lr-tb")
     root1.bind(minimum_height=root1.setter('height'))
     i = 0
     for row in rows:
         for col in row:
             if i == 0:
                 root1.add_widget(
                     MDLabel(text=str(col),
                             height=30,
                             size_hint_x=1 / 4,
                             size_hint_y=None,
                             halign="center",
                             font_style="Body1"))
             else:
                 root1.add_widget(
                     MDLabel(text=str(col),
                             height=30,
                             size_hint_x=1 / 4,
                             size_hint_y=None,
                             halign="center",
                             font_style="Body2"))
         if i == 0:
             root1.add_widget(MDSeparator())
         i = i + 1
     temp.add_widget(root1)
     tab.add_widget(temp)
Beispiel #3
0
    def buildscorecard(self, filename, id_string,con):

        scorecard = ScoreCardItem()
                
        k = 0
        with open(filename) as csv_file:
            csv_reader = csv.reader(csv_file, delimiter=',')
            data = DataBowl()
            textmatch="CSK/RCB-09-04-2021"
            matlbl = MDLabel(text=textmatch, adaptive_size=True)
            scorecard.add_widget(matlbl)
            sep = MDSeparator(height="1dp")
            scorecard.add_widget(sep)

            for row in csv_reader:

                for columns in row:
                    if k == 0:
                        lbl1 = MDLabel(text=columns, font_style="Overline")
                        data.add_widget(lbl1)
                    if k == 1:
                        lbl1 = MDLabel(text="[b]"+columns+"[b]",markup=True, font_style="Caption")
                        data.add_widget(lbl1)
                    if k == 2:
                        lbl1 = MDLabel(text=columns, font_style="Caption")
                        data.add_widget(lbl1)
                    if k == 3:
                        lbl1 = MDLabel(text=columns, font_style="Caption")
                        data.add_widget(lbl1)
                    if k == 4:
                        lbl1 = MDLabel(text=columns, font_style="Caption")
                        data.add_widget(lbl1)
                k += 1
        scorecard.add_widget(data)
        return scorecard 
Beispiel #4
0
    def __init__(self, list_content, **kwargs):
        super().__init__(**kwargs)
        self.ids.title.theme_text_color = "Custom"
        self.ids.title.text_color = (1, 1, 1, 1)

        self.ids.spacer_top_box.add_widget(MDSeparator())
        self.ids.spacer_bottom_box.add_widget(MDSeparator())

        height = 0
        for item in list_content:
            if issubclass(item.__class__, BaseListItem):
                height += item.height  # calculate height contents
                self.edit_padding_for_item(item)
                self.ids.box_items.add_widget(item)

        self.ids.scroll.height = height
Beispiel #5
0
def card(content, title=None, background_color=None, size=(0.7, 0.5)):
    """Вывод диалоговых окон с кастомным контентом."""

    if not background_color:
        background_color = [1.0, 1.0, 1.0, 1]

    card = MDCard(size_hint=(1, 1),
                  padding=5)  # , background_color=background_color)

    if title:
        box = BoxLayout(orientation="vertical", padding=dp(8))
        box.add_widget(
            MDLabel(
                text=title,
                theme_text_color="Secondary",
                font_style="Title",
                size_hint_y=None,
                height=dp(36),
            ))
        box.add_widget(MDSeparator(height=dp(1)))
        box.add_widget(content)
        card.add_widget(box)
    else:
        card.add_widget(content)

    dialog = ModalView(size_hint=size, background_color=[0, 0, 0, 0.2])
    dialog.add_widget(card)
    # dialog.open()

    return dialog
Beispiel #6
0
def processmanager(processname:str):
    """ Displaying active background process to the user"""
    pm = ProcessManagerItem()
    boxlayout = BoxLayout(orientation="vertical")
    main_label = MDLabel(
        text="Process running",
        theme_text_color= "Custom",
        text_color= (1, 1, 1, 1),
        size_hint_y= None,
        adaptive_height= True,
        )
    boxlayout.add_widget(main_label)
    sep = MDSeparator(height= "1dp", color='cyan')
    boxlayout.add_widget(sep)
    process_label = MDLabel(text= processname,
                            theme_text_color= "Custom",
                            text_color= (1, 1, 1, 1),)
    boxlayout.add_widget(process_label)
    boxlayout2 = BoxLayout(orientation= "vertical")
    pb = MDProgressBar(type= "determinate", running_duration= 1, catching_duration= 1.5)
    boxlayout2.add_widget(pb)
    pb.start()
    boxlayout.add_widget(boxlayout2)
    pm.add_widget(boxlayout)
    return pm
Beispiel #7
0
    def __init__(self, screen, routine, number, grid, **kwargs):
        super(RoutineCard, self).__init__(**kwargs)
        self.screen, self.number, self.routine = screen, number, routine
        self.size_hint = [None, None]
        self.height = 190
        self.orientation = "vertical"

        KivyLabel(grid=self,
                  font_size=25,
                  halign="left",
                  size_hint=[1, None],
                  height=30,
                  text=f"  {routine.name}")
        self.add_widget(MDSeparator(height=2))

        exercise_number, super_set_number = 0, 0
        for exercise_set in routine.exercises:
            if isinstance(exercise_set, SuperSet):
                super_set_number += 1

        if super_set_number != 0:
            super_set_text = f"{super_set_number} Super Sets"
            if super_set_number == 1:
                super_set_text = "1 Super Set"
            KivyLabel(grid=self,
                      font_size=16,
                      halign="left",
                      size_hint=[1, None],
                      height=30,
                      text=f"    {super_set_text}")
            exercise_number += 1

        for exercise_set in routine.exercises:
            if isinstance(exercise_set, Exercise):
                exercise_number += 1
                if exercise_number <= 4:
                    KivyLabel(grid=self,
                              font_size=16,
                              halign="left",
                              size_hint=[1, None],
                              height=30,
                              text=f"    {exercise_set.base_exercise.name}")
            last_exercise = exercise_set

        if exercise_number > 4:
            more_exercises_text = f"{exercise_number - 4} More Exercises"
            if exercise_number - 4 == 1:
                more_exercises_text = last_exercise.base_exercise.name
            KivyLabel(grid=self,
                      font_size=16,
                      halign="left",
                      size_hint=[1, None],
                      height=30,
                      text=f"    {more_exercises_text}")
        self.add_widget(MDLabel())

        grid.add_widget(self)
Beispiel #8
0
 def buildDropDown(self, args):
     self.ids.dropdown_item.text = self.initial_selected_text
     self.menu = DropDown()
     for each in self.menu_items:
         btn = DropItem(text=each.split(".")[0], icon="music-note",
                        icon_color=random.choice(clr))
         btn.bind(on_release=lambda btn: self.set_item(self.menu, btn))
         self.menu.add_widget(btn)
         self.menu.spacing = 0
         self.menu.add_widget(MDSeparator())
Beispiel #9
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        Window.bind(on_resize=self.update_width)

        self.md_bg_color = (
            self.theme_cls.bg_dark if not self.md_bg_color else self.md_bg_color
        )

        if self.size_hint == [1, 1] and (
            DEVICE_TYPE == "desktop" or DEVICE_TYPE == "tablet"
        ):
            self.size_hint = (None, None)
            self.width = min(dp(560), Window.width - self.width_offset)
        elif self.size_hint == [1, 1] and DEVICE_TYPE == "mobile":
            self.size_hint = (None, None)
            self.width = min(dp(280), Window.width - self.width_offset)

        if not self.title:
            self._spacer_top = 0

        if not self.buttons:
            self.ids.root_button_box.height = 0
        else:
            self.create_buttons()

        update_height = False
        if self.type in ("simple", "confirmation"):
            if self.type == "confirmation":
                self.ids.spacer_top_box.add_widget(MDSeparator())
                self.ids.spacer_bottom_box.add_widget(MDSeparator())
            self.create_items()
        if self.type == "custom":
            if self.content_cls:
                self.ids.container.remove_widget(self.ids.scroll)
                self.ids.container.remove_widget(self.ids.text)
                self.ids.spacer_top_box.add_widget(self.content_cls)
                self.ids.spacer_top_box.padding = (0, "24dp", "16dp", 0)
                update_height = True
        if self.type == "alert":
            self.ids.scroll.bar_width = 0

        if update_height:
            Clock.schedule_once(self.update_height)
 def add_footer(self, footer):
     if footer:
         self.content_cls.add_widget(MDSeparator())
         footer_text = SweetAlertLabel(
             text=footer,
             font_style=self.font_style_footer,
             theme_text_color="Custom",
             text_color=get_color_from_hex("#429cf4"),
         )
         self.content_cls.add_widget(footer_text)
Beispiel #11
0
    def update(self):
        self.main_lbl1.text, self.oil_lbl.text = '', ''
        self.card_list.children = []
        session = Session(bind=engine)
        q = session.query(Visit).all()
        pay = session.query(Oil).all()

        for i in q:
            if i.month == Container.MONTHS[Container.MONTH] and int(
                    i.date[:4]) == Container.YEAR:
                if i.money == 0:
                    self.card_list.add_widget(
                        CardItem(
                            text=
                            f'{i.date[8:10]}-{Container.DAYS[int(i.date[17:18])]}: {i.type.upper()}',
                            secondary_text=f'{i.address.title()}',
                            tertiary_text=f'{i.name.title()}; {i.distance}км'))
                    Container.COUNT_STR += 1
                    Container.COUNT_DISTANCE += i.distance

                if i.money != 0:
                    Container.COUNT_MONEY += i.money
                    self.card_list.add_widget(
                        PayCardItem(
                            text=
                            f'{i.date[8:10]}-{Container.DAYS[int(i.date[17:18])]}: Оплата {i.money} ',
                            secondary_text=f'# {i.name.lower()}'))
                    for a in range(3):
                        self.card_list.add_widget(MDSeparator())

        for w in pay:
            if w.month == Container.MONTHS[Container.MONTH] and int(
                    w.date[:4]) == Container.YEAR:
                Container.COUNT_PAY += w.pay
        self.main_lbl1.text = f'Выездов: {Container.COUNT_STR}\nДорога: {Container.COUNT_DISTANCE * 2}км;' \
                              f' {Container.COUNT_PAY}₽\nЗП: {Container.COUNT_MONEY - Container.COUNT_PAY}'
        Container.COUNT_MONEY = 0
        Container.COUNT_STR = 0
        Container.COUNT_DISTANCE = 0
        Container.COUNT_PAY = 0
        self.main_toolbar.title = f'{Container.MONTHS[Container.MONTH]} {Container.YEAR}'

        # update oil
        for i in pay:
            if i.comment:
                self.oil_lbl.text = f'{i.id})  {i.date[8:10]}-{Container.DAYS[int(i.date[17:18])]}  ' \
                                    f'{i.pay}  ({i.comment})\n\n' + \
                    self.oil_lbl.text
            else:
                self.oil_lbl.text = f'{i.id})  {i.date[8:10]}-{Container.DAYS[int(i.date[17:18])]}  {i.pay}\n\n' + \
                                    self.oil_lbl.text
        self.oil_toolbar.text = Container.MONTHS[Container.MONTH]
        session.close()
Beispiel #12
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        self.color_bg = kwargs.get('color_bg', self.theme_cls.bg_dark)
        if 'color_bg' in kwargs:
            del kwargs['color_bg']

        if self.size_hint == [1, 1] and DEVICE_TYPE == "mobile":
            self.size_hint = (None, None)
            self.width = dp(280)
        elif self.size_hint == [1, 1] and DEVICE_TYPE == "desktop":
            self.size_hint = (None, None)
            self.width = dp(560)

        if not self.title:
            self._spacer_top = 0

        if not self.buttons:
            self.ids.root_button_box.height = 0
        else:
            self.create_buttons()

        update_height = False
        if self.type in ("simple", "confirmation"):
            if self.type == "confirmation":
                self.ids.spacer_top_box.add_widget(MDSeparator())
                self.ids.spacer_bottom_box.add_widget(MDSeparator())
            self.create_items()
        if self.type == "custom":
            if self.content_cls:
                self.ids.container.remove_widget(self.ids.scroll)
                self.ids.container.remove_widget(self.ids.text)
                self.ids.spacer_top_box.add_widget(self.content_cls)
                self.ids.spacer_top_box.padding = (0, "24dp", "16dp", 0)
                update_height = True
        if self.type == "alert":
            self.ids.scroll.bar_width = 0

        if update_height:
            Clock.schedule_once(self.update_height)
Beispiel #13
0
    def add_order_admin(self):
        try:
            if self.food_count == 0:
                print("num>", self.admin_phone)
                self.food_count = self.food_count + 1
                food = self.root.ids.food_cat
                import firebase_admin
                firebase_admin._apps.clear()
                from firebase_admin import credentials, initialize_app, db
                if not firebase_admin._apps:
                    cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")
                    initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})

                    if self.admin_phone != "0788204327":
                        store = db.reference("Yummy").child("Admin").child(self.admin_phone).child("Orders")
                        stores = store.get()
                        print(stores)
                        count = 0
                        for y, x in stores.items():
                            print(x)
                            food_categories = category()
                            del_btn = MDIconButton(icon="delete", on_release=self.remove_widgets,
                                                   pos_hint={"center_x": .9, "center_y": .3}, theme_text_color="Custom",
                                                   text_color={60 / 255, 66 / 255, 75 / 255}, user_font_size="26sp")
                            count += 1
                            # food_categories.md_bg_color = 245 / 255, 0 / 255, 72 / 255, 1
                            food_categories.id = y
                            del_btn.id = y
                            food_categories.md_bg_color = 121 / 255, 174 / 255, 141 / 255, 1
                            food_categories.add_widget(Labels(text="Admin-phone:" + " " + str(x['Phone number'])))
                            food_categories.add_widget(Labels(text="Phone:" + " " + y))
                            food_categories.add_widget(MDSeparator(height="5dp"))
                            food_categories.add_widget(Labels(text="Amount:" + " " + " " + str(x['amount'])))
                            food_categories.add_widget(Labels(text="Location:" + " " + " " + str(x['location'])))
                            food_categories.add_widget(
                                Labels(text="Product-Name:" + " " + " " + str(x['product name'])))
                            food_categories.add_widget(Labels(text="Quantity:" + " " + " " + str(x['quantity'])))
                            food_categories.add_widget(Labels(text="Time-Ordered:" + " " + " " + str(x['time'])))
                            food_categories.add_widget(del_btn)
                            food.add_widget(food_categories)
                        self.spin_active = False
                        self.order_number = str(count)
                    else:
                        self.add_order()

            else:
                pass
        except:
            toast("no internet")
            self.spin_active = False
Beispiel #14
0
 def open_camera_list(self, inst):
     menu = DropDown(auto_width=False, width=200)
     try:
         from pygrabber.dshow_graph import FilterGraph
         device_list = FilterGraph().get_input_devices()
     except:
         device_list = []
     for i, each in enumerate(device_list):
         btn = DropItem(text=each, icon="webcam", font_size=15)
         btn.camera_indx = i
         btn.bind(on_release=lambda btn: self.set_item(menu, btn))
         menu.add_widget(btn)
         menu.spacing = 0
         menu.add_widget(MDSeparator())
     menu.open(inst)
Beispiel #15
0
    def buildDropDown(self, args):
        #Load All Notes
        with open('utils/notes.json', 'r') as file:
            self.music_notes = json.load(file)

        #check if select instr is available or not
        from utils.selected_instrument import manual_instr
        if (self.selected_instr not in instruments_items + manual_instr):
            self.ids.instr_drop.text = "Piano"
            self.selected_instr = "piano"

        #build instr dropdown
        self.instrumentmenu = DropDown()
        for each in instruments_items + manual_instr:
            btn = DropItem(text=each.capitalize(), icon="piano")
            btn.bind(
                on_release=lambda btn: self.set_item(self.instrumentmenu, btn))
            self.instrumentmenu.add_widget(btn)
            self.instrumentmenu.spacing = 0
            self.instrumentmenu.add_widget(MDSeparator())
        self.add_mapping_table()
Beispiel #16
0
    def create_header_menu(self):
        """Creates a menu in the file manager header."""

        with open(
                os.path.join(os.path.dirname(__file__), "data",
                             "header_menu.json"),
                encoding="utf-8",
        ) as data:
            menu_header = ast.literal_eval(data.read())
            for name_icon_item in menu_header:
                self.ids.header_box_menu.add_widget(
                    MDIconButton(
                        icon=name_icon_item,
                        user_font_size="18sp",
                        disabled=True if name_icon_item
                        not in ("home", "settings") else False,
                        md_bg_color_disabled=(0, 0, 0, 0),
                    ))
        self.ids.header_box_menu.add_widget(
            MDSeparator(orientation="vertical"))
        self.ids.header_box_menu.add_widget(
            MDIconButton(
                icon="cog",
                user_font_size="18sp",
                on_release=self.show_settings,
            ))
        background_normal = os.path.join(
            self.data_dir,
            "images",
            "bg-field.png"
            if self.theme_cls.theme_style == "Light" else "bg-field-dark.png",
        )
        self.instance_search_field = FileManagerTextFieldSearch(
            background_normal=background_normal,
            background_active=background_normal,
            manager=self,
        )
        self.ids.header_box_menu.add_widget(Widget())
        self.ids.header_box_menu.add_widget(self.instance_search_field)
Beispiel #17
0
    def add_exercise_info(self, exercise, show_add_button):
        self.clear_widgets()
        self.add = True
        self.exercise = exercise
        self.padding, self.spacing = [10, 10], [0, 5]

        KivyLabel(self,
                  30,
                  "center",
                  text=f"{exercise.name} info",
                  size_hint=[1, 1 / 10])
        self.add_widget(MDSeparator(height=2))
        KivyLabel(self,
                  25,
                  "center",
                  text=f"{exercise.name} info coming soon!",
                  size_hint=[1, 8 / 10])

        button_hint = [1, None]
        if show_add_button:
            button_hint = [1 / 2, None]

        grid = GridLayout(cols=2, size_hint=[1, None], spacing=[10, 0])
        KivyButton(grid,
                   L_GREEN,
                   25,
                   self.remove_card,
                   size_hint=button_hint,
                   text="Cancel")
        if show_add_button:
            KivyButton(grid,
                       L_GREEN,
                       25,
                       self.add_exercise,
                       button_hint,
                       text="Add Exercise")
        self.add_widget(grid)
Beispiel #18
0
 def add_image_herbs(self, cat, screen):
     from connection_status import connect
     if self.herbs_count == 0:
         self.herbs_count = self.herbs_count + 1
         if connect():
             food = self.root.ids.herb_cat
             from firebase_admin import credentials, initialize_app, db
             cred = credentials.Certificate("farmzon-abdcb-c4c57249e43b.json")
             default_app = initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'},
                                          name="herbs")
             store = db.reference("Categories_url", default_app).child(cat)
             stores = store.get()
             for y, x in stores.items():
                 self.real_source = x["url"]
                 food_categories = category()
                 food_categories.add_widget(Labels(text=y))
                 food_categories.add_widget(MDSeparator(height="1dp"))
                 food_categories.add_widget(cat_image(source=self.real_source))
                 food.add_widget(food_categories)
                 sm = self.root
                 sm.current = screen
     else:
         sm = self.root
         sm.current = screen
Beispiel #19
0
    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
Beispiel #20
0
    def __init__(self, screen, **kwargs):
        super(PersonalCard, self).__init__(**kwargs)
        self.screen = screen
        self.size_hint = [1, 0.79]
        self.orientation = "vertical"
        self.padding = [30, 0]
        self.elevation = 0

        self.grid = GridLayout(cols=1, spacing=0, size_hint_y=None)
        self.grid.bind(minimum_height=self.grid.setter('height'))

        self.grid.add_widget(
            SignupLabel("Let's get physical,",
                        28,
                        halign="left",
                        size_hint=[1, None],
                        height=25))
        self.grid.add_widget(
            SignupLabel("Sign up to continue!",
                        24, (129, 129, 129, 1),
                        halign="left",
                        size_hint=[1, None],
                        height=25))
        self.grid.add_widget(MDSeparator(height=2))

        self.main_grid = GridLayout(cols=1, spacing=[0, 12], padding=[20, 10])
        self.grid.add_widget(self.main_grid)

        self.username_input = UsernameInput(size_hint=[1, None], height=150)
        self.main_grid.add_widget(self.username_input)
        self.email_input = EmailInput(size_hint=[1, None], height=150)
        self.main_grid.add_widget(self.email_input)
        self.password_input = PasswordInput(size_hint=[1, None], height=150)
        self.main_grid.add_widget(self.password_input)
        self.all_inputs = [
            self.username_input, self.email_input, self.password_input
        ]

        self.main_grid.add_widget(MDSeparator(height=2))

        button_grid = GridLayout(cols=2,
                                 size_hint=[1, None],
                                 height=100,
                                 spacing=[10, 0])
        button_grid.add_widget(
            SignupButton("Back",
                         self.back_action,
                         size_hint=[1, None],
                         height=50))
        button_grid.add_widget(
            SignupButton("Continue",
                         self.continue_action,
                         size_hint=[1, None],
                         height=50))
        self.main_grid.add_widget(button_grid)

        self.grid.add_widget(MDLabel())

        scroll = ScrollView(size_hint=(1, 0.79),
                            size=(Window.width, Window.height))
        scroll.add_widget(self.grid)

        self.add_widget(scroll)
Beispiel #21
0
    def show_routine(self, routine):
        self.ids.routine_display_grid.clear_widgets()
        self.selected_routine = routine

        spare_height = Window.size[1] - 330

        title_grid = GridLayout(cols=2)
        self.ids.routine_display_grid.add_widget(title_grid)
        KivyLabel(grid=title_grid,
                  font_size=(45 - len(routine.name)),
                  halign="left",
                  text=routine.name,
                  size_hint=[1 / 2, None],
                  height=50)
        KivyLabel(grid=title_grid,
                  font_size=(45 - len(routine.name)),
                  halign="left",
                  text=routine.name,
                  size_hint=[1 / 2, None],
                  height=50)
        KivyButton(grid=title_grid,
                   md_bg_color=L_GREEN,
                   font_size=15,
                   on_release_action=self.hide_routine,
                   size_hint=[1 / 2, None],
                   text="Back",
                   height=50)

        set_number, exercise_number = 0, 0

        for exercise_set in routine.exercises:
            if isinstance(exercise_set, SuperSet):
                set_number += 1
            elif isinstance(exercise_set, Exercise):
                exercise_number += 1

        for exercise_set in routine.exercises:

            spare_height -= 11
            if spare_height < 80:
                break
            self.ids.routine_display_grid.add_widget(
                MDSeparator(height=1, size_hint=[1, None]))
            if isinstance(exercise_set, SuperSet):
                set_text = "set"
                if exercise_set.sets != 1:
                    set_text += "s"
                KivyLabel(
                    grid=self.ids.routine_display_grid,
                    font_size=20,
                    halign="left",
                    text=
                    f"Super Set - {exercise_set.sets} {set_text} for each exercise:",
                    height=20,
                    size_hint=[1, None])
                spare_height -= 40
                set_number -= 1
                for exercise in exercise_set.super_set_exercises:
                    if spare_height < 40:
                        break
                    rep_text = "rep"
                    if exercise.reps != 1:
                        rep_text += "s"
                    KivyLabel(
                        grid=self.ids.routine_display_grid,
                        font_size=20,
                        halign="left",
                        size_hint=[1, None],
                        text=
                        f"    {exercise.base_exercise.name} - {exercise.reps} {rep_text}",
                        height=20)
                    spare_height -= 30
            elif isinstance(exercise_set, Exercise):
                set_text = "set"
                if exercise_set.sets != 1:
                    set_text += "s"
                rep_text = "rep"
                if exercise_set.reps != 1:
                    rep_text += "s"
                KivyLabel(
                    grid=self.ids.routine_display_grid,
                    font_size=20,
                    halign="left",
                    height=20,
                    size_hint=[1, None],
                    text=
                    f"{exercise_set.base_exercise.name} - {exercise_set.sets} {set_text} of {exercise_set.reps} {rep_text}"
                )
                spare_height -= 30
                exercise_number -= 1

        if set_number != 0:
            self.ids.routine_display_grid.add_widget(
                MDSeparator(height=1, size_hint=[1, None]))
            KivyLabel(grid=self.ids.routine_display_grid,
                      font_size=20,
                      halign="left",
                      height=20,
                      text=f"+{set_number} more super-set")

        if exercise_number != 0:
            self.ids.routine_display_grid.add_widget(
                MDSeparator(height=1, size_hint=[1, None]))
            exercise_remain_text = "more exercise"
            if exercise_number > 1:
                exercise_remain_text += "s"
            KivyLabel(grid=self.ids.routine_display_grid,
                      font_size=20,
                      halign="left",
                      height=20,
                      size_hint=[1, None],
                      text=f"+{exercise_number} {exercise_remain_text}")

        self.ids.routine_display_grid.add_widget(MDSeparator(height=1))

        action_grid = GridLayout(cols=3,
                                 size_hint=[1, None],
                                 spacing=[10, 0],
                                 height=50)
        self.ids.routine_display_grid.add_widget(action_grid)
        action_button_dict = {
            "Start Routine": self.start_routine,
            "Edit Routine": self.edit_routine,
            "Delete Routine": self.delete_routine
        }

        for button_text, action in action_button_dict.items():
            KivyButton(grid=action_grid,
                       md_bg_color=L_GREEN,
                       font_size=15,
                       on_release_action=action,
                       size_hint=[1 / 3, None],
                       text=button_text)

        KivyLabel(self.ids.routine_display_grid)

        Animation(x=0, duration=0.2).start(self.ids.routine_display)
Beispiel #22
0
    def __init__(self, screen, **kwargs):
        super(HealthCard, self).__init__(**kwargs)
        self.screen = screen
        self.size_hint = [1, 0.79]
        self.orientation = "vertical"
        self.padding = [30, 0]
        self.spacing = [0, 10]
        self.elevation = 0

        self.grid = GridLayout(cols=1, spacing=0, size_hint_y=None)
        self.grid.bind(minimum_height=self.grid.setter('height'))

        self.grid.add_widget(
            SignupLabel("We need some information about you,",
                        28,
                        halign="left",
                        size_hint=[1, None],
                        height=25))
        self.grid.add_widget(
            SignupLabel("Please type them in below!",
                        24, (129, 129, 129, 1),
                        halign="left",
                        size_hint=[1, None],
                        height=25))
        self.grid.add_widget(MDSeparator(height=2))

        self.main_grid = GridLayout(cols=1, spacing=[0, 12], padding=[20, 10])
        self.grid.add_widget(self.main_grid)

        self.unit_select = SignupButtonList(["Metric (kg)", "Imperial (lb)"],
                                            self.change_units, "Weight Units",
                                            0)
        self.main_grid.add_widget(self.unit_select)
        self.gender_select = SignupButtonList(["Male", "Female", "Other"],
                                              label="Gender")
        self.main_grid.add_widget(self.gender_select)
        self.weight_input = HealthInput("weight", "weight", True, 500)
        self.main_grid.add_widget(self.weight_input)
        self.height_input = HealthInput("height", "human-male-height", True,
                                        300)
        self.main_grid.add_widget(self.height_input)
        self.age_input = HealthInput("Age", "calendar-today", False, 100)
        self.main_grid.add_widget(self.age_input)

        self.all_inputs = [
            self.weight_input, self.height_input, self.age_input
        ]

        self.grid.add_widget(MDSeparator(height=2))

        button_grid = GridLayout(cols=2,
                                 size_hint=[1, None],
                                 height=100,
                                 spacing=[10, 0])
        button_grid.add_widget(
            SignupButton("Back",
                         self.back_action,
                         size_hint=[1, None],
                         height=50))
        button_grid.add_widget(
            SignupButton("Continue",
                         self.continue_action,
                         size_hint=[1, None],
                         height=50))
        self.main_grid.add_widget(button_grid)

        self.grid.add_widget(MDLabel())

        scroll = ScrollView(size_hint=(1, 0.79),
                            size=(Window.width, Window.height))
        scroll.add_widget(self.grid)

        self.add_widget(scroll)

        self.change_units()
Beispiel #23
0
    def __init__(self, screen, **kwargs):
        super(ExperienceCard, self).__init__(**kwargs)
        self.screen = screen
        self.size_hint = [1, 0.79]
        self.orientation = "vertical"
        self.padding = [30, 0]
        self.spacing = [0, 10]
        self.elevation = 0

        self.grid = GridLayout(cols=1, spacing=0, size_hint_y=None)
        self.grid.bind(minimum_height=self.grid.setter('height'))

        self.grid.add_widget(
            SignupLabel("What are your fitness goals?",
                        28,
                        halign="left",
                        size_hint=[1, None],
                        height=25))
        self.grid.add_widget(
            SignupLabel("We need this to produce the best routines for you!",
                        20, (129, 129, 129, 1),
                        halign="left",
                        size_hint=[1, None],
                        height=25))
        self.grid.add_widget(MDSeparator(height=2))

        self.main_grid = GridLayout(cols=1, spacing=[0, 12], padding=[20, 10])
        self.grid.add_widget(self.main_grid)

        self.main_grid.add_widget(SignupLabel("Experience?", 25, height=25))

        self.experience_list = SignupButtonList([
            "Beginner\n(New to fitness)",
            "Intermediate\n(Been to the gym\na couple times)",
            "Advanced\n(Know my way\nround the gym)"
        ],
                                                button_height=100)
        self.main_grid.add_widget(self.experience_list)

        self.main_grid.add_widget(MDSeparator(height=2))

        self.main_grid.add_widget(
            SignupLabel("Goals? - Pick the Two Main Ones", 25, height=25))
        self.multi_goal_select = MultiButtonListSelect({
            "Lose Weight/Fat":
            "Lose Fat",
            "Gain Muscle":
            "M",
            "Increase Strength":
            "Strength",
            "More Endurance":
            "Endurance",
            "Grow Athletic Skill":
            "Athletic",
            "Expand Joint Flexibility":
            "Flexibility"
        })
        self.main_grid.add_widget(self.multi_goal_select)

        self.main_grid.add_widget(MDSeparator(height=2))

        self.main_grid.add_widget(
            SignupLabel("What equipment do you have available?", 25,
                        height=25))
        self.equipment_list = EquipmentSelectList()
        self.main_grid.add_widget(self.equipment_list)

        self.main_grid.add_widget(MDSeparator(height=2))

        self.main_grid.add_widget(
            SignupLabel("How often do want to work out per week?",
                        20,
                        height=25))
        self.frequency = HealthInput("Workout Frequency", "calendar-week",
                                     False, 7)
        self.main_grid.add_widget(self.frequency)

        self.main_grid.add_widget(MDSeparator(height=2))

        button_grid = GridLayout(cols=2,
                                 size_hint=[1, None],
                                 height=100,
                                 spacing=[10, 0])
        button_grid.add_widget(
            SignupButton("Back",
                         self.back_action,
                         size_hint=[1, None],
                         height=50))
        button_grid.add_widget(
            SignupButton("Continue",
                         self.continue_action,
                         size_hint=[1, None],
                         height=50))
        self.main_grid.add_widget(button_grid)

        self.grid.add_widget(MDLabel())

        scroll = ScrollView(size_hint=(1, 0.79),
                            size=(Window.width, Window.height))
        scroll.add_widget(self.grid)

        self.add_widget(scroll)
    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)
Beispiel #25
0
    def on_pre_enter(self):
        txt = requests.get(URL + "api/parcel/", headers=auth_header()).json()

        title = MDLabel(text="Wszystkie przesyłki:",
                        font_style="H4",
                        pos_hint={
                            "center_x": .5,
                            "center_y": .5
                        },
                        size_hint=(None, None),
                        size=("400dp", "90dp"))
        self.box_layout.add_widget(title)
        for parcel in txt['_embedded']['parcelList']:
            card = MDCard(orientation="vertical",
                          padding="8dp",
                          size_hint=(None, None),
                          size=("400dp", "180dp"),
                          pos_hint={
                              "center_x": .5,
                              "center_y": .5
                          })
            label_id = MDLabel(text="Id: " + str(parcel['id']))
            label_reciever = MDLabel(text="Odbiorca: " +
                                     str(parcel['receiver']),
                                     font_style='Caption')
            label_postoffice = MDLabel(text="Skrytka pocztowa: " +
                                       str(parcel['postOffice']),
                                       font_style='Caption')
            label_size = MDLabel(text="Rozmiar: " + str(parcel['size']),
                                 font_style='Caption')
            label_status = MDLabel(text="Status: " +
                                   self.status_for_name(str(parcel['status'])),
                                   font_style='Caption')
            card.add_widget(label_id)
            card.add_widget(MDSeparator())
            card.add_widget(label_reciever)
            card.add_widget(label_postoffice)
            card.add_widget(label_size)
            card.add_widget(label_status)
            card.add_widget(MDSeparator())
            box_layout = MDBoxLayout(adaptive_height=True,
                                     padding=5,
                                     spacing=5)
            wd_button = MDRectangleFlatButton(
                text='W drodze',
                size_hint=(.333, None),
                on_release=partial(self.button_clicked,
                                   uri=str(parcel["_links"]["self"]["href"]),
                                   status="IN_TRANSPORT",
                                   label=label_status))
            d_button = MDRectangleFlatButton(
                text='Dostarczono',
                size_hint=(.333, None),
                on_release=partial(self.button_clicked,
                                   uri=str(parcel["_links"]["self"]["href"]),
                                   status="DELIVERED",
                                   label=label_status))
            o_button = MDRectangleFlatButton(
                text='Odebrano',
                size_hint=(.333, None),
                on_release=partial(self.button_clicked,
                                   uri=str(parcel["_links"]["self"]["href"]),
                                   status="PICKED_UP",
                                   label=label_status))
            box_layout.add_widget(wd_button)
            box_layout.add_widget(d_button)
            box_layout.add_widget(o_button)
            card.add_widget(box_layout)
            self.box_layout.add_widget(card)