def test_collect_category_settings(self): entry_field_1 = combobox() entry_field_2 = combobox() entry_field_3 = combobox() entry_field_1.set("Movies") entry_field_2.set("Add category") entry_field_3.set("TV") added_categories = [ entry_field_1, entry_field_2, entry_field_3, ] self.service.collect_category_settings(added_categories) self.assertEqual(len(self.service.categories), 2) self.assertEqual(self.service.categories[0], "Movies") self.assertEqual(self.service.categories[1], "TV")
def test_collect_player_settings(self): entry_field_1 = combobox() entry_field_2 = combobox() entry_field_3 = combobox() entry_field_4 = combobox() entry_field_1.set("samushka") entry_field_2.set("Add player") entry_field_3.set("") entry_field_4.set("Player 4") added_players = [ entry_field_1, entry_field_2, entry_field_3, entry_field_4, ] self.service.collect_player_settings(added_players) self.assertEqual(len(self.service.players), 2) self.assertEqual(self.service.players[0], "samushka") self.assertEqual(self.service.players[1], "Player 4")
def _build_entry_widgets(self): """Builds the widgets of the parent window.""" self.category_combobox = combobox(self.window, 43) self.category_combobox['values'] = self.service.get_categories() self.category_combobox.set(self.service.get_item_for_editing(self.selected)[0]) self.category_combobox.grid(column=0, row=2, columnspan=2, padx=X) self.difficulty_combobox = combobox(self.window, 43) self.difficulty_combobox['values'] = self.service.get_difficulties() self.difficulty_combobox.state(['readonly']) self.difficulty_combobox.set(self.service.get_item_for_editing(self.selected)[1]) self.difficulty_combobox.grid(column=0, row=4, columnspan=2, padx=X) self.question_entry = edit_textbox(self.window, 6) self.question_entry.grid(column=0, row=6, columnspan=2, padx=X) self.question_entry.insert(tk.END, self.service.get_item_for_editing(self.selected)[2]) self.answer_entry = edit_textbox(self.window, 4) self.answer_entry.grid(column=0, row=8, columnspan=2, padx=X) self.answer_entry.insert(tk.END, self.service.get_item_for_editing(self.selected)[3])
def _build_category_combobox(self): """Builds a combobox widget. Returns: A combobox with all categories in the database. """ category_combobox = combobox(self.window, 43) category_combobox['values'] = self.service.get_categories() category_combobox.grid(column=0, row=2, columnspan=2, padx=X) return category_combobox
def _build_difficulty_combobox(self): """Builds a combobox widget. Returns: A combobox with the default difficulties. """ difficulty_combobox = combobox(self.window, 43) difficulty_combobox['values'] = self.service.get_difficulties() difficulty_combobox.state(['readonly']) difficulty_combobox.set(self.service.get_difficulties()[1]) difficulty_combobox.grid(column=0, row=4, columnspan=2, padx=X) return difficulty_combobox
def _build_board_size_combobox(self): """Builds the board size selection widget. Returns: board_size_combobox (widget): The board size selection box. """ board_size_combobox = combobox(self.window) board_size_combobox['values'] = [ x[0] for x in self.service.get_default_board_sizes() ] board_size_combobox.state(['readonly']) board_size_combobox.set(self.service.get_default_board_sizes()[2][0]) board_size_combobox.grid(column=2, row=2, padx=X) return board_size_combobox
def _build_player_entries(self): """Builds the player name entry widgets with a loop. The default value of the first entry widget is set to the currently logged in user's username. Returns: player_comboboxes (list): Widgets for selecting players. """ player_comboboxes = [] for i in range(0, 6): player_combobox = combobox(self.window) player_combobox['values'] = self.service.get_default_players()[1:] if i == 0: player_combobox.set(f"{self.service.get_default_players()[0]}") else: player_combobox.set("Add player") player_combobox.grid(column=0, row=2 + i, padx=X) player_comboboxes.append(player_combobox) player_comboboxes[0].focus() return player_comboboxes
def _build_category_comboboxes(self): """Builds the category selection widgets with a loop. The default value of the first two boxes is set to the Open Trivia Database category. Returns: category_comboboxes (list): Widgets for selecting categories. """ category_comboboxes = [] categories = self.service.get_categories() for i in range(0, 12): category_combobox = combobox(self.window) category_combobox['values'] = categories category_combobox.state(['readonly']) if i in (0, 1): category_combobox.set(categories[-2]) else: category_combobox.set("Add category") category_combobox.grid(column=1, row=2 + i) category_comboboxes.append(category_combobox) return category_comboboxes
def test_collect_board_size_settings(self): selected_board_size = combobox() selected_board_size.set("Medium") self.service.collect_board_size_settings(selected_board_size) self.assertEqual(self.service.board_size, 5)