Example #1
0
    def __init__(self, view, parent):
        '''
        Constructor
        '''

        theme1 = "orange2"
        theme2 = "orange2"
        theme3 = "#B00B1E"
        button_font = tk.font.Font(family="Times", size="20")

        #Window which will display when the player will start the application
        self._difficulty_window = None

        #Creates the scene
        tk.Frame.__init__(self, parent, bg=theme1)
        self.place(relwidth=1, relheight=1)

        #Creates label title
        titre = tk.Label(self,
                         text="Love Letters",
                         font=tk.font.Font(family="Times",
                                           size="35",
                                           weight="bold",
                                           slant="italic"),
                         bg=theme1,
                         fg=theme3,
                         pady=25)
        titre.pack(side=tk.TOP, fill=tk.BOTH)

        #Creates transition button
        start_button = tk.Button(
            self,
            text="Commencer partie",
            command=lambda: self.display_difficulty_choice(view),
            pady=75,
            bg=theme3,
            fg=theme2,
            relief=tk.RIDGE,
            font=button_font)
        start_button.pack(side=tk.TOP, fill=tk.BOTH)

        #Button returning the URL which gives the rules
        rules_button = tk.Button(self,
                                 text="Règles",
                                 command=lambda: Controller.consulter_regles(),
                                 pady=75,
                                 bg=theme3,
                                 fg=theme2,
                                 relief=tk.RIDGE,
                                 font=button_font)
        rules_button.pack(side=tk.TOP, fill=tk.BOTH)

        #Button used to leave the game
        exit_button = tk.Button(self,
                                text="Quitter",
                                command=lambda: Controller.quitter_jeu(),
                                pady=75,
                                bg=theme3,
                                fg=theme2,
                                relief=tk.RIDGE,
                                font=button_font)
        exit_button.pack(side=tk.TOP, fill=tk.BOTH)
Example #2
0
    def init_features(self, view, theme1, container, text_font):
        theme = 'goldenrod'

        #Container of quit button
        quit_frame = tk.Frame(self,
                              bg=theme1,
                              highlightthickness=3,
                              highlightbackground=theme)

        #Creates of the button used to leave the application
        button_quit = tk.Button(quit_frame,
                                text="Quit game",
                                command=lambda: Controller.quitter_jeu(),
                                font=text_font,
                                bg=theme1,
                                fg=theme)
        quit_frame.place(relx=0, rely=1, y=-button_quit.winfo_reqheight() - 5)
        button_quit.pack()

        #Creates the label displaying the player whose turn it is
        self._tour_label = tk.Label(self, font=text_font, fg=theme, bg=theme1)
        self._tour_label.place(relx=0.2, rely=0.7)

        #Creates the label displaying the gamee's info
        self._info_label = tk.Label(self,
                                    text="Idle",
                                    font=text_font,
                                    fg=theme,
                                    bg=theme1)
        self._info_label.place(rely=0.325)

        #Creates the label displaying the last card played
        self._last_card_label = tk.Label(self,
                                         bg=theme1,
                                         image=self._images["Cache"])
        self._last_card_label.place(rely=0.325,
                                    y=self._info_label.winfo_reqheight())

        #Creates the frame which is displayed on top of the game scene when the user wants to view the cards or when he has to chose between multiple options
        #(after playing the prince or the guard for instance)
        self._special_frame = SpecialFrame(container, theme1, self)

        #Container of the feature buttons
        container_features = tk.Frame(self,
                                      bg=theme1,
                                      highlightthickness=3,
                                      highlightbackground=theme)
        container_features.pack(side=tk.RIGHT)

        #Button used to display the list of cards of the game
        boutton_reminder = tk.Button(
            container_features,
            command=lambda: self._special_frame.display_reminder(),
            text="Rappel des cartes",
            bg=theme1,
            fg=theme,
            font=text_font)
        boutton_reminder.pack(fill=tk.BOTH)

        #Button used to display the cards played
        boutton_played_cards = tk.Button(
            container_features,
            text="Consulter cartes jouées",
            command=lambda: Controller.display_played_cards(self._special_frame
                                                            ),
            bg=theme1,
            fg=theme,
            font=text_font)
        boutton_played_cards.pack()

        #Frames containing the player's tokens
        self._token_frames = (tk.Frame(self,
                                       bg=theme1,
                                       highlightbackground=theme,
                                       highlightthickness=3),
                              tk.Frame(self,
                                       bg=theme1,
                                       highlightbackground=theme,
                                       highlightthickness=3))

        #Picture of a token
        self._tokenimage = tk.PhotoImage(file="Jeton.png")

        #Frames containing the labels (one for the player and one for the AI)
        self._token_frames[0].place(relx=0.75, rely=0.05)
        self._token_frames[1].place(relx=0.75, rely=0.7)
        #Labels "points"
        points_label = (tk.Label(self._token_frames[0],
                                 text="points : ",
                                 bg=theme1,
                                 fg=theme,
                                 font=text_font),
                        tk.Label(self._token_frames[1],
                                 text="points : ",
                                 bg=theme1,
                                 fg=theme,
                                 font=text_font))
        points_label[0].grid(row=0, column=0)
        points_label[1].grid(row=0, column=0)

        #Tokens labels
        self._token_labels = []

        #Creation of the list containing the list of all the labels of the player and a list for all the buttons of the AI
        for i in range(0, 2):
            temp = []
            for _ in range(0, 5):
                temp.append(
                    tk.Label(self._token_frames[i],
                             bg=theme1,
                             fg=theme,
                             image=self._tokenimage))
            self._token_labels.append(temp)

        self._details_label = tk.Label(self,
                                       bg=theme1,
                                       fg=theme,
                                       font=text_font)