示例#1
0
    def make_copy(self):
        for x in self.winfo_children():
            if (x.winfo_ismapped()):
                self._copie.append(x)

        self.stop_display(
        )  #In order to display the elements again, we refresh the frame
        Controller.display_played_cards(self, True)  #Display the cards played
示例#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)