Exemplo n.º 1
0
    def _build_button_widgets(self):
        """Builds the button widgets of the parent window."""

        button(self.window, "Save", self._handle_question_item_update
        ).grid(column=0, row=10)

        button(self.window, "Cancel", self._open_custom_content_view
        ).grid(column=1, row=10)
Exemplo n.º 2
0
    def _build_widgets(self):
        """Builds the widgets of the parent window."""

        title = display_textbox(self.window, 1, 85, TITLE_FONT)
        title.place(x=30, y=30)
        title.insert(tk.END, "Laps per player")
        title.config(state=DISABLED)

        self._draw_player_names()
        self._draw_player_laps()

        button(self.window, "Got it!",
               self.window.destroy).place(x=180, y=260, anchor="center")
Exemplo n.º 3
0
    def _build_action_buttons(self):
        """Builds the action buttons of the parent view."""

        button(
            self.window,
            "Proceed",
            self._handle_login_event,
        ).grid(column=0, row=5, padx=X, pady=Y, sticky="e")

        button(
            self.window,
            "Users",
            self._show_users,
        ).grid(column=1, row=5, padx=X, pady=Y, sticky="w")
Exemplo n.º 4
0
    def _build_widgets(self):
        """Builds the widgets of the parent window."""

        title = display_textbox(self.window, 1, 60, TITLE_FONT)
        title.place(x=30, y=30)
        title.insert(tk.END, "Trivioboros")
        title.config(state=DISABLED)

        rules = display_textbox(self.window, 40, 87, TEXT_FONT)
        rules.place(x=30, y=80)
        rules.insert(tk.END, self._game_rules_text())
        rules.config(state=DISABLED)

        button(
            self.window,
            "Got it!",
            self.window.destroy,
        ).place(x=370, y=580, anchor="center")
Exemplo n.º 5
0
    def _build_buttons(self):
        """Builds the button widgets of the parent window."""

        button(self.window, "  Logout  ", self._handle_logout).grid(column=0,
                                                                    row=0,
                                                                    padx=X)

        button(self.window, "Custom Content",
               self._open_questions_view).grid(column=2, row=0, padx=X)

        button(self.window, "Game Rules", self._open_rules_view).grid(column=0,
                                                                      row=14,
                                                                      padx=X)

        button(self.window, "About Open Trivia DB",
               show_about_otdb_dialog).grid(column=1, row=14, padx=X)

        button(self.window, "Start Game",
               self._handle_game_start_event).grid(column=2, row=14, padx=X)
    def _build_create_widgets(self):
        """Builds the left-side widgets of the parent window."""

        title_label(self.window, "Create"
        ).grid(column=0, row=0, columnspan=2)

        basic_label(self.window, "Category"
        ).grid(column=0, row=1, columnspan=2)
        self.category_combobox = self._build_category_combobox()
        self.category_combobox.focus()

        basic_label(self.window, "Difficulty"
        ).grid(column=0, row=3, columnspan=2)
        self.difficulty_combobox = self._build_difficulty_combobox()

        basic_label(self.window, "Question"
        ).grid(column=0, row=5, columnspan=2)
        self.question_entry = edit_textbox(self.window, 6)
        self.question_entry.grid(column=0, row=6, columnspan=2)

        basic_label(self.window, "Answer"
        ).grid(column=0, row=7, columnspan=2)
        self.answer_entry = edit_textbox(self.window, 4)
        self.answer_entry.grid(column=0, row=8, columnspan=2)

        button(self.window, "Save", self._handle_save_event
        ).grid(column=0, row=9, pady=Y)
        button(self.window, "Clear", self._clear_entries
        ).grid(column=1, row=9, pady=Y)
        button(self.window, "Back to Settings", self._open_settings_view
        ).grid(column=0, row=11, columnspan=2, pady=Y)
Exemplo n.º 7
0
    def _show_answer(self):
        """Shows the correct answer and buttons for confirming
        whwther the player's answer was correct."""

        self.answer_textbox = display_textbox(self.window, 3, 45)
        self.answer_textbox.place(x=30, y=420, anchor="w")
        self.answer_textbox.insert(tk.END,
                                   self.service.get_answer_for_player())
        self.answer_textbox.config(state=DISABLED)

        self.answer_correct_btn = button(
            self.window,
            "Player's answer was correct",
            self._handle_correct_answer,
        )
        self.answer_correct_btn.place(x=30, y=490, anchor="w")

        self.answer_incorrect_btn = button(
            self.window,
            "Player's answer was incorrect",
            self._handle_incorrect_answer,
        )
        self.answer_incorrect_btn.place(x=300, y=490, anchor="w")
    def _build_browse_widgets(self):
        """Builds the right-side widgets of the parent window."""

        title_label(self.window, "Browse"
        ).grid(column=2, row=0, columnspan=3)

        self.listbox = self._build_listbox()

        button(self.window, "Edit", self._handle_edit
        ).grid(column=2, row=11)
        button(self.window, "Delete selected", self._handle_delete_item
        ).grid(column=3, row=11)
        button(self.window, "Delete all", self._handle_delete_all
        ).grid(column=4, row=11)
Exemplo n.º 9
0
    def _handle_question_phase(self):
        """Shows the current category and question,
        and builds a button for showing the correct answer.

        If an error occurs while retrieving a category from the Open Trivia Database,
        i.e. the category is None, calls another method that will handle the situation,
        so that the UI won't get stuck in an unplayable state."""

        if self.service.get_category_for_player() is None:
            self._handle_category_error()
        else:
            self.category_board.highlight_category(
                self.service.current_category_index)

            self.question_textbox = display_textbox(self.window, 7, 45)
            self.question_textbox.place(x=30, y=285, anchor="w")
            self.question_textbox.insert(
                tk.END, self.service.get_question_for_player())
            self.question_textbox.config(state=DISABLED)

            self.show_answer_btn = button(self.window, "Show answer",
                                          self._show_answer)
            self.show_answer_btn.place(x=280, y=420, anchor="center")
Exemplo n.º 10
0
    def _build_right_side_canvas_buttons(self):
        """Builds buttons for showing rules and statistics,
        and quitting the current game session."""

        button(
            self.window,
            "Quit",
            self._handle_quit_game,
        ).place(x=1260, y=30, anchor="e")

        button(
            self.window,
            "Rules",
            self._open_rules_view,
        ).place(x=1260, y=655, anchor="e")

        button(
            self.window,
            "Statistics",
            self._open_statistics_view,
        ).place(x=1260, y=690, anchor="e")
Exemplo n.º 11
0
    def _build_cast_button(self):
        """Builds a button for casting the die."""

        cast_btn = button(self.window, "Cast",
                          lambda: self._handle_die_cast_event(cast_btn))
        cast_btn.place(x=917, y=420, anchor="center")