示例#1
0
    def update_languages(self):

        list = self.ids.language_list

        for language in Language:
            chip = MDChip(text=language.name, icon='', check=True)
            list.add_widget(chip)
示例#2
0
    def update_genres(self):

        list = self.ids.genre_list

        for genre in Genre:
            chip = MDChip(text=genre.name, icon='', check=True)
            list.add_widget(chip)
示例#3
0
 def call(self, *args):
     theme_cls = ThemeManager()
     self.ids.stack.clear_widgets()
     sent = self.ids.sentence.text.lower()
     for idx, word in enumerate(sent.split()):
         chip = MDChip(label=word,
                    callback=self.do_something,
                    icon='check-network-outline',
                    selected_chip_color=theme_cls.accent_color,
                    )
         self.ids.stack.add_widget(chip)
示例#4
0
    def __init__(self, **kwargs):
        super(StartScreen, self).__init__(**kwargs)

        self.username = MDLabel()

        self.username.text = "Не определено"
        self.username.pos_hint = {"center_y": informationBlockStart}
        self.username.font_size = 20
        self.username.halign = "center"

        self.avatar = AsyncImage(source = "https://vk.com/images/camera_200.png?ava=1")

        self.avatar.size_hint = [0.35, 0.35]
        self.avatar.pos_hint = {"center_x": 0.5, "center_y": informationBlockStart - 0.135}

        self.tracksCount = MDChip()
        self.tracksCount.label = "Нет аудиозаписей"
        self.tracksCount.icon = ""
        self.tracksCount.pos_hint = {"center_x": 0.5, "center_y": informationBlockStart - 0.268}

        self.startToPlay = MDRaisedButton()
        self.exitFromAccount = MDRaisedButton()
        self.aboutGame = MDRaisedButton()

        self.startToPlay.text = "Начать играть"
        self.exitFromAccount.text = "Выход"
        self.aboutGame.text = "Об игре"

        self.startToPlay.pos_hint = {"center_x": 0.5, "center_y": controlPanelBlockStart}
        self.exitFromAccount.pos_hint = {"center_x": 0.305, "center_y": controlPanelBlockStart - 0.07}
        self.aboutGame.pos_hint = {"center_x": 0.695, "center_y": controlPanelBlockStart - 0.07}

        self.startToPlay.md_bg_color = [0, 0.75, 0.30, 1]
        self.exitFromAccount.md_bg_color = [0.93, 0.26, 0.26, 1]
        self.aboutGame.md_bg_color = [0.3, 0.3, 0.3, 1]

        self.startToPlay.size_hint = [0.75, 0.08]
        self.exitFromAccount.size_hint = [0.36, 0.04]
        self.aboutGame.size_hint = [0.36, 0.04]

        self.startToPlay.font_size = 17

        self.add_widget(self.username)
        self.add_widget(self.avatar)
        self.add_widget(self.tracksCount)
        self.add_widget(self.startToPlay)
        self.add_widget(self.exitFromAccount)
        self.add_widget(self.aboutGame)
示例#5
0
    def __init__(self, genres, artists, **kwargs):
        super().__init__(**kwargs)
        from kivymd.uix.chip import MDChip
        for genre in genres:
            chip = MDChip(
                text=genre.capitalize(),
                color=self.theme_cls.primary_light,
            )
            chip.remove_widget(chip.ids.icon)
            self.root.ids.selected_genres.add_widget(chip)

        for artist in artists:
            chip = MDChip(
                text=artist,
                color=self.theme_cls.primary_light,
            )
            chip.remove_widget(chip.ids.icon)
            self.root.ids.selected_artists.add_widget(chip)
示例#6
0
 def __init__(self, callback=None, **kwargs):
     from kivymd.uix.chip import MDChip
     super().__init__(**kwargs)
     self.app = MDApp.get_running_app()
     self.app.artists_page = self
     self.loading = loading_spinner(pos_hint={'center_x': .5, 'center_y': .5})
     self.finish = callback if callback is not None else self.finish
     self.get_track_trigger = None
     self.add_widget(self.loading)
     for artist in self.app.artists:
         artist_chip = MDChip(
             text=artist,
             text_color=(1, 1, 1, 0.87),
             icon_color=(1, 1, 1, 0.87),
             icon='close',
             on_release=self.remove_artist,
         )
         self.selected_artists.add_widget(artist_chip)
示例#7
0
    def add_artist(self, artist):
        from kivymd.uix.chip import MDChip
        page = self.app.artists_page
        page.search_layout.ids.search_field.text = ''
        page.search_layout.ids.hits.clear_widgets()

        if artist not in self.app.artists:
            self.app.artists.append(artist)
            artist_chip = MDChip(
                text=artist,
                text_color=(1, 1, 1, 0.87),
                icon_color=(1, 1, 1, 0.87),
                icon='close',
                on_release=page.remove_artist,
            )
            page.selected_artists.add_widget(artist_chip)
        else:
            toast('Artist already selected.')
        Logger.info("ARTISTS: %s", self.app.artists)
示例#8
0
 def __init__(self, **kwargs):
     super(mainscreen, self).__init__(**kwargs)
     kword = Jurecom.kwd
     for i in range(15):
         self.kwd.add_widget(
             MDChip(label=kword.iloc[i]['KEYWORD'], callback=self.check1))
    def diff_sel(self, menu, menu_item):
        global push, pull, leg
        print(menu.caller.text)  #menu.caller.text gives the text of the helper
        print(menu_item.text + "\n")

        if menu.caller.text == "Push":

            if menu_item.text == "Easy":
                #Clearing previous widgets
                for child in self.children[:]:
                    if isinstance(child, MDChip):
                        if child.text in push[0] + push[1] + push[2]:
                            self.remove_widget(child)

                push_e = {}

                for ex, y in zip(push[0], np.arange(0.73, -1, -0.05)):
                    push_e[round(y, 2)] = ex

                for pos, ex in push_e.items():
                    chip = MDChip(text=ex,
                                  pos_hint={
                                      'center_x': 0.2,
                                      'center_y': float(pos)
                                  },
                                  on_release=self.selected_push,
                                  check=True)
                    chip.color = chip_color
                    chip.icon = "coffee"
                    self.add_widget(chip)

            elif menu_item.text == "Medium":
                #Clearing previous widgets.
                for child in self.children[:]:
                    if isinstance(child, MDChip):
                        if child.text in push[0] + push[1] + push[2]:
                            self.remove_widget(child)

                push_m = {}

                for ex, y in zip(push[1], np.arange(0.73, -1, -0.05)):
                    push_m[round(y, 2)] = ex

                for pos, ex in push_m.items():
                    chip = MDChip(text=ex,
                                  pos_hint={
                                      'center_x': 0.2,
                                      'center_y': float(pos)
                                  },
                                  on_release=self.selected_push,
                                  check=True)
                    chip.color = chip_color
                    chip.icon = "coffee"
                    self.add_widget(chip)

            elif menu_item.text == "Hard":
                #Clearing previous widgets.
                for child in self.children[:]:
                    if isinstance(child, MDChip):
                        if child.text in push[0] + push[1] + push[2]:
                            self.remove_widget(child)

                push_h = {}

                for ex, y in zip(push[2], np.arange(0.73, -1, -0.05)):
                    push_h[round(y, 2)] = ex

                for pos, ex in push_h.items():
                    chip = MDChip(text=ex,
                                  pos_hint={
                                      'center_x': 0.2,
                                      'center_y': float(pos)
                                  },
                                  on_release=self.selected_push,
                                  check=True)
                    chip.color = chip_color
                    chip.icon = "coffee"
                    self.add_widget(chip)

        if menu.caller.text == "Pull":
            if menu_item.text == "Easy":
                #Clearing previous widgets.
                for child in self.children[:]:
                    if isinstance(child, MDChip):
                        if child.text in pull[0] + pull[1] + pull[2]:
                            self.remove_widget(child)

                pull_e = {}

                for ex, y in zip(pull[0], np.arange(0.73, -1, -0.05)):
                    pull_e[round(y, 2)] = ex

                for pos, ex in pull_e.items():
                    chip = MDChip(text=ex,
                                  pos_hint={
                                      'center_x': 0.505,
                                      'center_y': float(pos)
                                  },
                                  on_release=self.selected_pull,
                                  check=True)
                    chip.color = chip_color
                    chip.icon = "coffee"
                    self.add_widget(chip)

            elif menu_item.text == "Medium":
                #Clearing previous widgets.
                for child in self.children[:]:
                    if isinstance(child, MDChip):
                        if child.text in pull[0] + pull[1] + pull[2]:
                            self.remove_widget(child)

                pull_m = {}

                for ex, y in zip(pull[1], np.arange(0.73, -1, -0.05)):
                    pull_m[round(y, 2)] = ex

                for pos, ex in pull_m.items():
                    chip = MDChip(text=ex,
                                  pos_hint={
                                      'center_x': 0.505,
                                      'center_y': float(pos)
                                  },
                                  on_release=self.selected_pull,
                                  check=True)
                    chip.color = chip_color
                    chip.icon = "coffee"
                    self.add_widget(chip)

            elif menu_item.text == "Hard":
                #Clearing previous widgets.
                for child in self.children[:]:
                    if isinstance(child, MDChip):
                        if child.text in pull[0] + pull[1] + pull[2]:
                            self.remove_widget(child)

                pull_h = {}

                for ex, y in zip(pull[2], np.arange(0.73, -1, -0.05)):
                    pull_h[round(y, 2)] = ex

                for pos, ex in pull_h.items():
                    chip = MDChip(text=ex,
                                  pos_hint={
                                      'center_x': 0.505,
                                      'center_y': float(pos)
                                  },
                                  on_release=self.selected_pull,
                                  check=True)
                    chip.color = chip_color
                    chip.icon = "coffee"
                    self.add_widget(chip)

        if menu.caller.text == "Legs":
            if menu_item.text == "Easy":
                #Clearing previous widgets.
                for child in self.children[:]:
                    if isinstance(
                            child, MDChip
                    ):  #Checks if the widget exists or not. similar to type()
                        if child.text in leg[0] + leg[1] + leg[2]:
                            self.remove_widget(child)

                leg_e = {}

                for ex, y in zip(leg[0], np.arange(0.73, -1, -0.05)):
                    leg_e[round(y, 2)] = ex

                for pos, ex in leg_e.items():
                    chip = MDChip(text=ex,
                                  pos_hint={
                                      'center_x': 0.8,
                                      'center_y': float(pos)
                                  },
                                  on_release=self.selected_legs,
                                  check=True)
                    chip.color = chip_color
                    chip.icon = "coffee"
                    self.add_widget(chip)

            elif menu_item.text == "Medium":
                #Clearing previous widgets.
                for child in self.children[:]:
                    if isinstance(child, MDChip):
                        if child.text in leg[0] + leg[1] + leg[2]:
                            self.remove_widget(child)

                leg_m = {}

                for ex, y in zip(leg[1], np.arange(0.73, -1, -0.05)):
                    leg_m[round(y, 2)] = ex

                for pos, ex in leg_m.items():
                    chip = MDChip(text=ex,
                                  pos_hint={
                                      'center_x': 0.8,
                                      'center_y': float(pos)
                                  },
                                  on_release=self.selected_legs,
                                  check=True)
                    chip.color = chip_color
                    chip.icon = "coffee"
                    self.add_widget(chip)

            elif menu_item.text == "Hard":
                #Clearing previous widgets.
                for child in self.children[:]:
                    if isinstance(child, MDChip):
                        if child.text in leg[0] + leg[1] + leg[2]:
                            self.remove_widget(child)

                leg_h = {}

                for ex, y in zip(leg[2], np.arange(0.73, -1, -0.05)):
                    leg_h[round(y, 2)] = ex

                for pos, ex in leg_h.items():
                    chip = MDChip(text=ex,
                                  pos_hint={
                                      'center_x': 0.8,
                                      'center_y': float(pos)
                                  },
                                  on_release=self.selected_legs,
                                  check=True)
                    chip.color = chip_color
                    chip.icon = "coffee"
                    self.add_widget(chip)
    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)