Exemple #1
0
 def nouvelle_partie(self):
     """
     """
     _np = Bouton(self, "Nouvelle partie",
                  self._controller.relance_nouvelle_partie)
     _np.fixer_des_options(font=("Helvetica", 20), padx=2, pady=5)
     _np.grid(row=0, column=0, padx=5, pady=5)
Exemple #2
0
 def affiche_les_operateurs(self):
     """
     """
     for i in range(0, len(LES_OPERATEURS)):
         _temp = Bouton(self, LES_OPERATEURS[i], lambda indice = i:self._controller.get_indice_operateur(indice))
         _temp.fixer_des_options(font=("Helvetica", 15), padx=5, pady=3)
         _temp.grid(row = 2, column = i+1, padx = 3, pady = 3)
         self._liste_btn_operateurs.append(_temp)
Exemple #3
0
 def bouton_solution(self):
     """
     """
     _b = Bouton(self, "Solution", self._controller.generer_solution)
     _b.fixer_des_options(font=("Helvetica", 20),
                          padx=5,
                          pady=5,
                          borderwidth=2,
                          background="#3CB371",
                          fg="white",
                          activebackground="#2E8B57",
                          activeforeground="white")
     _b.grid(row=0, column=3, padx=5, pady=5)
Exemple #4
0
class DefinirTemps(Frame):
    """
    """
    def __init__(self, master):
        Frame.__init__(self, master)

    def champ_saisie(self):
        self._temps = StringVar()
        Entry(self, font=("Helvetica", 10),
              textvariable=self._temps).grid(row=2, column=0)

    def get_temps(self):
        """
        """
        if len(self._temps.get()) == 0:
            self._temps = 45
            return self._temps
        else:
            return self._temps

    def set_temps(self, temps):
        return self._temps.set(temps)

    def bouton_definir(self, label, fn_callback):
        self._creer = Bouton(self, label, fn_callback)
        self._creer.fixer_des_options(font=("Helvetica", 10), padx=10, pady=5)
        self._creer.grid(row=4, column=0)

    def label_champ(self):
        Label(
            self,
            text=
            "Veuillez définir le temps (Par defaut le temps est définie à 45 secondes):",
            font=("Helvetica", 15)).grid(row=0, column=0)

    def destructeur(self):
        """
        """
        self.destroy()
Exemple #5
0
class CreationJoueur(Frame):
    """
    """
    def __init__(self, master):
        Frame.__init__(self, master)

        self.label_champ()
        self.champ_saisie()

    def champ_saisie(self):
        self._pseudo = StringVar()
        Entry(self, font=("Helvetica", 10),
              textvariable=self._pseudo).grid(row=2, column=0)

    def bouton_creer(self, label, fn_callback):
        self._creer = Bouton(self, label, fn_callback)
        self._creer.fixer_des_options(font=("Helvetica", 10), padx=10, pady=5)
        self._creer.grid(row=4, column=0)

    def label_champ(self):
        Label(self,
              text="Veuillez saisir un pseudo s'il vous plaît :",
              font=("Helvetica", 15)).grid(row=0, column=0)
Exemple #6
0
class Accueil(Frame):
    """
        cette classe définie les widgets de la vue d'accueil de l'application
    """
    
    def __init__(self, master):
        Frame.__init__(self, master)
        
        self.label_nom_du_jeu()
        self.label_description()
    
    
    
    def creation_bouton_entrainement(self, label="Entrainement", fn_callback=None):
        self._entrainement = Bouton(self, label, fn_callback)
        self._entrainement.fixer_des_options(font=("Helvetica", 20), padx = 10, pady = 5)
        self._entrainement.grid(row=2, column=0, padx = 2, pady = 2)
        
        
    def creation_bouton_jeu_a_deux(self, label="Jeu à deux", fn_callback=None):
        self._jeu_a_deux = Bouton(self, label, fn_callback)
        self._jeu_a_deux.fixer_des_options(font=("Helvetica", 20), padx = 25, pady = 5)
        self._jeu_a_deux.grid(row=3, column=0,  padx = 2, pady = 2)
    
    def creation_bouton_quitter(self, label="Quitter", fn_callback=None):
        self._quitter = Bouton(self, label, fn_callback)
        self._quitter.fixer_des_options(font=("Helvetica", 20), padx = 10, pady = 5,underline=1, fg="red")
        self._quitter.grid(row=4, column=0,  padx = 2, pady = 2)
    
    
    def label_nom_du_jeu(self):
        Label(self, text=NOM_DU_JEU, font=("Helvetica", 25)).grid(row=0, column=0, pady = 50)
    
    def label_description(self):
        Label(self, text=DESCRIPTION, font=("Helvetica", 8, "italic"), wraplength=290).grid(row=5, column=0, pady = 20)
    
    def fixer_des_options(self, *options):
        """
            Permet de fixer des options de la frame 
        """
        self.config(*options)
Exemple #7
0
class VueManager(Frame):
    def __init__(self, master, controller):
        Frame.__init__(self, master)
        self._controller = controller

        self.text_p = StringVar()
        self.text_s = StringVar()

        self._section_2 = SectionDeux(self, self._controller)
        self._section_1 = SectionUne(self, self._controller)
        self._section_3 = SectionTrois(self, self._controller)

        #Ajout d'un menu
        menubar = Menu(master)
        optionmenu = Menu(menubar, tearoff=0)

        optionmenu.add_separator()

        optionmenu.add_command(label="Retour accueil",
                               command=self._controller.retourner_accueil)
        optionmenu.add_separator()
        optionmenu.add_command(label="Quitter", command=master.quit)
        menubar.add_cascade(label="Options", menu=optionmenu)

        aproposmenu = Menu(menubar, tearoff=0)
        aproposmenu.add_command(label="Description",
                                command=self.description_entrainement)
        menubar.add_cascade(label="A propos", menu=aproposmenu)

        master.config(menu=menubar)  #ajout du menu

    @property
    def section_2(self):
        return self._section_2

    @property
    def section_1(self):
        return self._section_1

    @property
    def section_3(self):
        return self._section_3

    def bouton_effectuer_operation(self):
        """
        """
        self._bouton_effectuer = Bouton(
            self, "Effectuer", self._controller.effectuer_une_operation)
        self._bouton_effectuer.fixer_des_options(font=("Helvetica", 15),
                                                 padx=43,
                                                 pady=5,
                                                 state="disabled")
        self._bouton_effectuer.grid(row=2, column=0, padx=5, pady=5)

    def desactiver_bouton_effectuer(self):
        """
        """
        self._bouton_effectuer.fixer_des_options(state="disabled")

    def activer_bouton_effectuer(self):
        """
        """
        self._bouton_effectuer.fixer_des_options(state="normal")

    def relance_nouvelle_partie(self, nouveau_n, nouvelle_liste):
        """
        """
        self._section_1.update_label_n(
            nouveau_n)  #mettre la valeur à trouver à jour
        self._section_2.changer_les_plaques(
            nouvelle_liste)  #met à jour les plaques
        self._section_3.vider_historique()  #efface l'historique
        self._section_3.vider_solution()
        self.desactiver_bouton_effectuer()

    def activer_vue_entrainement(self):
        self.section_2.affiche_les_plaques(
            self._controller.les_plaques_tirees())
        self.section_2.affiche_les_operateurs()
        self.section_2.grid(row=1, column=0, padx=5, pady=5)

        self.section_1.nouvelle_partie()
        self.section_1.valeur_N(self._controller.tirer_n_aleatoirement())
        self.section_1.bouton_solution()
        self.section_1.grid(row=0, column=0, padx=5, pady=10)

        self.section_3.grid(row=3, column=0)

        self.bouton_effectuer_operation()

    def activer_vue_jeu_a_deux_part_1(self, temps, n):

        self._temps = self.section_1.label_compte_a_rebours(temps)
        self.section_1.valeur_N(n)
        self.section_1.bouton_stop()

        self.section_1.grid(row=0, column=0, padx=5, pady=10)

        self.update_profil(self._controller._joueur.nom)
        self.update_score(0)
        self.profil_joueur()
        self._profil.grid(row=4, column=0, pady=5)
        self._score.grid(row=5, column=0, pady=5)

    def activer_vue_jeu_a_deux_part_2(self, plaques):

        self.section_2.affiche_les_plaques(plaques)
        self.section_2.affiche_les_operateurs()
        self.section_2.grid(row=1, column=0, padx=5, pady=5)

        self.bouton_effectuer_operation()

    def veuillez_patienter(self):
        self._vp = Label(
            self,
            text=
            "En attente du deuxième joueur, veuillez patienter s'il vous plaît, merci !",
            font=("Helvetica", 20))
        self._vp.pack(pady=300)

    def supprimer_vp(self):
        self._vp.pack_forget()

    def description_entrainement(self):
        """
        """
        pass

    def profil_joueur(self):
        """
        """
        self._profil = Label(self,
                             text=self.text_p.get(),
                             font=("Helvetica", 15))
        self._score = Label(self,
                            text=self.text_s.get(),
                            font=("Helvetica", 15))

    def update_profil(self, pseudo):
        self.text_p.set("Profil :" + pseudo)

    def update_score(self, score):
        self.text_s.set("Score :" + str(score))

    def nombre_trouver(self):
        self._nb_trouver = StringVar()
        Label(self,
              text="Quel nombre avez-vous trouvé ? ",
              font=("Helvetica", 15)).grid(row=6, column=0, padx=5, pady=5)
        self._champ_nb_trouver = Entry(
            self, textvariable=self._nb_trouver).grid(row=7,
                                                      column=0,
                                                      padx=5,
                                                      pady=5)

    def get_nb_trouver(self):
        return self._nb_trouver.get()

    def btn_nb_trouver(self):
        self._btn_nb_trouver = Bouton(
            self, "Envoyer",
            lambda: self._controller.agent_nb_trouver(self.get_nb_trouver()))
        self._btn_nb_trouver.fixer_des_options(font=("Helvetica", 10),
                                               padx=10,
                                               pady=5)
        self._btn_nb_trouver.grid(row=8, column=0, padx=5, pady=5)

    def afficher_aprs_stop(self):
        """
        """
        self._label_trouver = Label(
            self,
            text=
            "Votre adversaire s'annonce avoir trouver, veuillez patienter svp !",
            font=("Helvetica", 15)).grid(row=3, column=0, pady=20)

    def supprimer_trouver(self):
        self._label_trouver.grid_forget()
Exemple #8
0
class SectionTrois(Frame):
    """
    """
    def __init__(self, master, controller):
        Frame.__init__(self, master)
        self._controller = controller

        self.labels_()
        self.liste_box_historique()
        self.liste_box_solution()
        self.btn_supp_derniere_opetation()

    def labels_(self):
        """
        """
        self._label = Label(self,
                            text="Historique de vos opérations",
                            font=("Helvetica", 10, "bold"),
                            pady=2)
        self._label.grid(row=0, column=0, padx=130, pady=5)

        self._label_s = Label(
            self,
            text=
            "Cliquez sur le bouton solution pour voir la resolution de cette partie !",
            font=("Helvetica", 10, "bold"),
            wraplength=200,
            pady=2)
        self._label_s.grid(row=0, column=1, padx=130, pady=5)

    def liste_box_historique(self):
        """
        """
        self._listebox_historique = Listbox(self,
                                            bd=2,
                                            relief="groove",
                                            width=50,
                                            font=("Helvetica", 10, "bold"),
                                            activestyle="none")
        self._listebox_historique.grid(row=1, column=0, pady=2)

    def liste_box_solution(self):
        self._listebox_solution = Listbox(self,
                                          bd=2,
                                          relief="groove",
                                          width=50,
                                          font=("Helvetica", 10, "bold"),
                                          activestyle="none")
        self._listebox_solution.grid(row=1, column=1, pady=2)

    def btn_supp_derniere_opetation(self):
        """
        """
        self._btn = Bouton(
            self, "SUPP derniere opération", lambda: self._controller.
            supprimer_derniere_operation(self._listebox_historique))
        self._btn.fixer_des_options(font=("Helvetica", 15),
                                    state="disabled",
                                    padx=2,
                                    pady=5)
        self._btn.grid(row=2, column=0, pady=5)

    def activer_btn_supp(self):
        """
        """
        self._btn.fixer_des_options(state="normal")

    def desactive_btn_supp(self):
        """
        """
        self._btn.fixer_des_options(state="disabled")

    def afficher_operation(self, operation, indice_operateur):
        """
            Affiche l'operation réçue en paramètre
        """
        if self._btn["state"] == "disabled":
            self.activer_btn_supp()

        if indice_operateur == 1:
            if operation[0] >= operation[1]:
                self._listebox_historique.insert('end', [
                    operation[0], LES_OPERATEURS[1], operation[1], "=",
                    operation[2]
                ])
            else:
                self._listebox_historique.insert('end', [
                    operation[1], LES_OPERATEURS[1], operation[0], "=",
                    operation[2]
                ])
        elif indice_operateur == 3:
            if operation[0] % operation[1] == 0:
                self._listebox_historique.insert('end', [
                    operation[0], LES_OPERATEURS[3], operation[1], "=",
                    operation[2]
                ])
            else:
                self._listebox_historique.insert('end', [
                    operation[1], LES_OPERATEURS[3], operation[0], "=",
                    operation[2]
                ])
        else:
            self._listebox_historique.insert('end', [
                operation[0], LES_OPERATEURS[indice_operateur], operation[1],
                "=", operation[2]
            ])

    def vider_historique(self):
        """
        """
        self._listebox_historique.delete(0, 'end')

    def vider_solution(self):
        """
        """
        self._listebox_solution.delete(0, 'end')
Exemple #9
0
class SectionUne(Frame):
    """
    """
    def __init__(self, master, controller):
        Frame.__init__(self, master)
        self._controller = controller

    def nouvelle_partie(self):
        """
        """
        _np = Bouton(self, "Nouvelle partie",
                     self._controller.relance_nouvelle_partie)
        _np.fixer_des_options(font=("Helvetica", 20), padx=2, pady=5)
        _np.grid(row=0, column=0, padx=5, pady=5)

    def valeur_N(self, n):
        """
        """
        self._n = StringVar()
        Label(self,
              textvariable=self._n,
              font=("Helvetica", 20, "bold"),
              bd=1,
              relief="groove",
              padx=30,
              pady=5).grid(row=0, column=1, padx=150)
        self._n.set(n)

    def update_label_n(self, n):
        """
            Met à jour la nouvelle valeur à trouver 
        """
        self._n.set(n)

    def bouton_solution(self):
        """
        """
        _b = Bouton(self, "Solution", self._controller.generer_solution)
        _b.fixer_des_options(font=("Helvetica", 20),
                             padx=5,
                             pady=5,
                             borderwidth=2,
                             background="#3CB371",
                             fg="white",
                             activebackground="#2E8B57",
                             activeforeground="white")
        _b.grid(row=0, column=3, padx=5, pady=5)

    def bouton_stop(self):
        """
        """
        self._btn = Bouton(self, "Stop",
                           self._controller.stop_compte_a_rebours)
        self._btn.fixer_des_options(font=("Helvetica", 20),
                                    padx=5,
                                    pady=5,
                                    borderwidth=2,
                                    background="#273746",
                                    fg="white",
                                    activebackground="#273746",
                                    activeforeground="white")
        self._btn.grid(row=0, column=3, padx=5, pady=5)

    def desactiver_btn_stop(self):
        self._btn.fixer_des_options(state="disable")

    def label_compte_a_rebours(self, temps=45):
        """
        """
        self._label_compte = Label(self, text="45 secondes")
        self._label_compte.config(font=("Helvetica", 10), padx=2, pady=5)
        self._label_compte.grid(row=0, column=0, padx=5, pady=5)
        self._id = None
        self._label_compte.after(
            1000, lambda: self._controller.compte_a_rebours(
                self._label_compte, temps, self._id))

    def stop_compte_a_rebours(self):
        self._label_compte.after_cancel(self._id)

    @property
    def get_temps(self):
        return self._temps