def generate_history_account_start_layout(self): history_account_start_layout_box = BoxLayout(orientation='vertical', spacing=12, size_hint=(.7, 1)) history_account_box = BoxLayout(orientation='horizontal', spacing=10) history_button = Button(text='History', font_size=20, on_release=self.go_to_history_page) accounts_button = Button(text=str(self.user[0]).upper(), font_size=20, background_color=Utils.get_color_from_letter( self.user[0]), on_release=self.go_to_login_page) history_account_box.add_widget(history_button) history_account_box.add_widget(accounts_button) history_account_start_layout_box.add_widget(history_account_box) Utils.add_empty_space(history_account_start_layout_box, (1, 2.4)) start_button_box = BoxLayout(orientation='vertical') start_button = Button(text='start', font_size=25, on_release=self.go_to_typing_page) start_button_box.add_widget(start_button) history_account_start_layout_box.add_widget(start_button_box) Utils.add_empty_space(history_account_start_layout_box, (1, 2.4)) self.root_widget.add_widget(history_account_start_layout_box)
def generate_metrics_and_cancel_box(self): # Initialize box to contain all metric buttons metrics_and_cancel_box = BoxLayout(orientation='vertical', spacing=15, size_hint=(.5, 1)) # Add average speed button self.speed_button = Button( text=f'Speed: {self.speed} WPM', font_size=20, color='white', background_normal='data/home_background.png') metrics_and_cancel_box.add_widget(self.speed_button) # Add accuracy button self.accuracy_button = Button( text=f'Accuracy: {self.accuracy}%', font_size=20, color='white', background_normal='data/home_background.png') metrics_and_cancel_box.add_widget(self.accuracy_button) # Add adjusted speed button self.adjusted_speed_button = Button( text=f'Adjusted Speed: {self.adjusted_speed} WPM', font_size=20, color='white', background_normal='data/home_background.png') metrics_and_cancel_box.add_widget(self.adjusted_speed_button) # Add timer self.timer_button = Button( text=f'time elapsed: 00:00', font_size=20, color='white', background_normal='data/home_background.png') metrics_and_cancel_box.add_widget(self.timer_button) # Add Show/Hide keyboard button self.show_hide_keyboard = Button(text=f'Show Keyboard', font_size=20) # metrics_and_cancel_box.add_widget(self.show_hide_keyboard) # Add Empty space Utils.add_empty_space(metrics_and_cancel_box, (1, 1.5)) # Add Cancel button self.cancel_button = Button(text='Back to Home', font_size=20) metrics_and_cancel_box.add_widget(self.cancel_button) # Add metrics and cancel box to the root widget self.root_widget.add_widget(metrics_and_cancel_box)
def generate_story_and_typing_box(self): # initialize box to contain story container and keyboard box story_container_and_typing_box = BoxLayout(orientation='vertical', spacing=15, size_hint_x=1.3) # Add story box self.typing_container = BoxLayout(orientation='vertical', spacing=40) with open(self.article_path, 'r', encoding='utf8') as story: lines = story.read().splitlines() self.typing_boxes = [] for line in lines: typing_box = TyperBox(self, document_sentence=line) self.typing_boxes.append(typing_box) for i in range(len(self.typing_boxes)): if i > 2: break if i == 0: self.typing_boxes[i].enable_and_focus() self.typing_container.add_widget(self.typing_boxes[i]) story_container_and_typing_box.add_widget(self.typing_container) Utils.add_empty_space(story_container_and_typing_box, (1, .5)) self.finish_button = Button(text='Finish Test', font_size=20, size_hint=(.3, .3), pos_hint={ 'x': .7, 'y': 0 }, on_release=self.end_test, disabled=True) story_container_and_typing_box.add_widget(self.finish_button) self.root_widget.add_widget(story_container_and_typing_box)
def generate_articles_layout(self): articles_layout_box = BoxLayout(orientation='vertical', spacing=12, size_hint=(.7, .9)) refresh_button = Button(text='Change story', font_size=15, size_hint=(1, .3), on_release=self.load_article) articles_layout_box.add_widget(refresh_button) articles_box = BoxLayout(orientation='vertical', spacing=12, size_hint=(1, 1.2)) change_article_button = Button(text='Change Story', font_size=20) # articles_box.add_widget(change_article_button) articles_layout_box.add_widget(articles_box) Utils.add_empty_space(articles_layout_box, (1, 1)) self.root_widget.add_widget(articles_layout_box)
def generate_metric_box(self): metric_box = BoxLayout(orientation='vertical', spacing=20) # get most recent results most_recent_metric = self.data_df.tail(1) metric_points = [(row['speed'], row['accuracy'], row['adjusted_speed']) for index, row in most_recent_metric.iterrows()] self.typing_speed, self.typing_accuracy, self.adjusted_speed = metric_points[ 0] # Create Stats labels stats_box = BoxLayout(orientation='vertical', spacing=10) speed_label = Label(text=f'Speed: {self.typing_speed} WPM', font_size=30) accuracy_label = Label(text=f'Accuracy: {self.typing_accuracy}%', font_size=30) adjusted_speed_label = Label( text=f'Adjusted Speed: {self.adjusted_speed} WPM', font_size=30) stats_box.add_widget(speed_label) stats_box.add_widget(accuracy_label) stats_box.add_widget(adjusted_speed_label) metric_box.add_widget(stats_box) # Create empty space Utils.add_empty_space(metric_box, (1, 1)) # Add home button home_button = Button(text='Go Home', font_size=15, on_release=partial( self.controller.initialize_home_page, self.user), size_hint=(.7, .3)) metric_box.add_widget(home_button) self.root_box.add_widget(metric_box)