class StatsByGame(Screen): player_name = StringProperty('') player_tree = DictProperty({}) rv_mod = ObjectProperty(None) stats = ObjectProperty(None) def __init__(self, **kwargs): super().__init__(**kwargs) self.message = MessagePopup() self.message.auto_dismiss = True def extract_players_games(self): self.stats = self.player_tree.xpath( '//table[@id="tblPlayerPhaseStatistics"]/tbody/tr/td/text()') if len(self.stats) != 0: data = access_per_game_stats(self.player_tree, self.player_name) self.rv_mod = RVMod(perf_data=data) self.add_widget(self.rv_mod) else: self.message.notification.text = 'No games played by ' + self.player_name + ' yet!' self.message.open() @staticmethod def call_menu_screen(*args): del App.get_running_app().root.screens_visited[1:] App.get_running_app().root.transition = FadeTransition(duration=.5) App.get_running_app().root.current = 'menu' def on_leave(self, *args): if len(self.stats) != 0: self.remove_widget(self.rv_mod)
def call_roster_screen(self, *args): conn = connectivity_status() if conn is True: if len(self.grid_teams.selected_roster) != 0: App.get_running_app().root.transition = FadeTransition( duration=.5) App.get_running_app().root.current = 'roster' else: message = MessagePopup() message.notification.text = 'Roster\'s announcement is pending!' message.open() Clock.schedule_once(message.dismiss, 2) else: App.get_running_app().root.show_popup(conn)
def __init__(self, **kwargs): super().__init__(**kwargs) self.show_stats = DisplayStats() self.message = MessagePopup() self.message.auto_dismiss = True
class Stats(Screen): player_tree = DictProperty({}) player_name = StringProperty('') player_photo = StringProperty('Images/NoImage.jpg') text_1 = StringProperty('') text_2 = StringProperty('') stats = ListProperty([]) rv = ObjectProperty(None) def __init__(self, **kwargs): super().__init__(**kwargs) self.show_stats = DisplayStats() self.message = MessagePopup() self.message.auto_dismiss = True def extract_players_data(self): info = self.player_tree.xpath( '//div[@class="summary-second"]/span/text()') pos = self.player_tree.xpath( '//div[@class="summary-first"]/span/span/text()') photo_url = self.player_tree.xpath( '//div[@class="player-img"]/img/@src') try: if len(photo_url) != 0: response = requests.get(photo_url[0]) player_photo = self.player_name + '.jpg' with open(player_photo, 'wb') as f: f.write(response.content) self.player_photo = player_photo else: self.player_photo = 'Images/NoImage.jpg' except requests.exceptions.RequestException as request_exceptions: logging.warning( 'Requests exceptions occurred: {}'.format(request_exceptions)) try: self.text_1 = pos[ 0] + '[color=FF6600]' + ' | ' + '[/color]' + pos[1] self.text_2 = info[0] + '[color=FF6600]' + ' | ' '[/color]' + info[1] + '[color=FF6600]' + ' | ' + \ '[/color]' + info[2] except IndexError as index_error: logging.warning('Index error occurred: {}'.format(index_error)) def select_stats(self, instance): self.stats = self.player_tree.xpath( '//table[@id="tblPlayerPhaseStatistics"]/tbody/tr/td/text()') if len(self.stats) != 0: if instance.text == 'Average Stats': average_stats = self.stats[-16:] if average_stats: self.rv = RV(update_dict(average_stats)) self.show_stats.title = 'Average Stats for ' + self.player_name elif instance.text == 'Total Stats': total_stats = self.stats[-35:-19] if total_stats: self.rv = RV(update_dict(total_stats)) self.show_stats.title = 'Total Stats for ' + self.player_name else: self.message.notification.text = 'No games played by ' + self.player_name + ' yet!' self.message.open() def on_rv(self, *args): self.show_stats.content = self.rv self.show_stats.open()
def __init__(self, **kwargs): super().__init__(**kwargs) self.message = MessagePopup() self.message.auto_dismiss = True
def show_popup(text_to_display): message = MessagePopup() message.notification.text = text_to_display message.open()
def __init__(self, **kwargs): super().__init__(**kwargs) self.message = MessagePopup() self.message.notification.text = 'Fetching teams...'
def __init__(self, **kwargs): super().__init__(**kwargs) self.message = MessagePopup() self.message.notification.text = 'Almost there...'