Пример #1
0
    def __init__(self, racine):
        self.racine = racine
        self.hanoi = hanoi.clHanoi(3)
        cadre_haut = Frame(racine, relief="ridge", borderwidth=2)

        gauche = Frame(cadre_haut)
        Label(gauche, text="Nb de disques : ").pack(side="top", padx=2, pady=0)
        self.nb_disques = IntVar()
        echelle = Scale(gauche, from_=3, to=10, orient="horizontal", tickinterval=1, variable=self.nb_disques)
        echelle.pack(side="top", expand="yes", fill="x", padx=2, pady=2)
        gauche.pack(side="left", expand="yes", fill="x")

        cadre_boutons = Frame(cadre_haut)
        Button(cadre_boutons, text="Commencer", command=self.Commencer).grid(row=0, column=0, sticky="nsew")
        Button(cadre_boutons, text="Solution", command=self.Solution).grid(row=1, column=0, sticky="nsew")
        Button(cadre_boutons, text="Options", command=self.Options).grid(row=0, column=1, sticky="nsew")
        Button(cadre_boutons, text="Quitter", command=self.Quitter).grid(row=1, column=1, sticky="nsew")
        cadre_boutons.pack(side="left")

        cadre_haut.pack(side="top", fill="x")

        self.dessin_tours = clDessinTours(racine, self.hanoi)
        self.dessin_tours.pack(side="top", expand="yes", fill="both")

        self.message = Label(racine, relief="ridge")
        self.message.pack(side="top", pady=2, expand="yes", fill="both")

        self.dessin_tours.Dessin()
        self.dessin_tours.bind("<ButtonPress-1>", self.ChoixTour)
        self.attente_tour_depart = 0
        self.tour_depart = -1
        self.Commencer()
Пример #2
0
 def Commencer(self):
     nb = self.nb_disques.get()
     self.hanoi = hanoi.clHanoi(nb)
     self.dessin_tours.hanoi = self.hanoi
     self.dessin_tours.Dessin()
     self.attente_tour_depart = 1
     self.mouvements = 0
     self.message.configure(text="Solution en %d mouvements minimum." % (2 ** nb - 1))
Пример #3
0
 def __init__ (self, hauteur) :
   self.hauteur = hauteur
   self.hanoi = hanoi.clHanoi(hauteur)
   self.solution_demandee = 0