“Proyecto Simple Tower of Hanoi Python con GUI” Código de respuesta

Proyecto Simple Tower of Hanoi Python con GUI

. 1  Import Tkinter
 2  from tkinter.scrolledtext Import ScrolledText
 . 3 the root = tkinter.Tk ()
 . 4 root.title ( ' Towers of Hanoi Solver ' )
 . 5 root.geometry ( ' 300x200 ' )
 . 6 root.resizable (width = False, height = True)
 7 tkinter.Label(root, text= ' Please enter the number of floors of the Tower of Hanoi ' , font=( ' Microsoft Yahei ' , 12 )).pack()
 8 var = tkinter.StringVar()
 9e = tkinter.Entry(root, textvariable = var)
 10  e.pack()
 11 t = tkinter.scrolledtext.ScrolledText(root)
 12 ans = []
 13  def hanoi(n, x, y, z):
 14      if n . 1 == :
 15          ans.append (+ x ' -> ' + Z)
 16      the else :
 . 17         Hanoi (n-1, x, Z, Y) # front n-1 on a plate moves from x to Y 
18 is         ans.append (+ x ' -> ' + Z) # the last tray from the lowermost to move the x Z 
. 19        Hanoi (n-1, y, X, Z) # to the n-1 in the y-plate moves to the Z 
20 is      return ANS
 21 is  DEF Calc ():
 22 is      del ANS [:]
 23 is      n-= int (var.get ( ))
 24      str2 = hanoi(n, ' x ' , ' y ' , ' z ' )
 25      t.delete(0.0 , tkinter.END)
 26      count = 0
 27      for stre in str2:
 28          count = count + 1
 29          t .insert(tkinter.END,' First ' + STR (COUNT) + ' Step: ' + + STRE ' /n- ' )
 30      t.Insert (1.0, ' [total ' + STR (COUNT) + ' Step]/n- ' )
 31 is      t.pack ( )
 32 tkinter.Button(root, text= " OK " , command= calc)
 .pack() 33 root.mainloop()
Frantic Flamingo

Proyecto Simple Tower of Hanoi Python con GUI

. 1  Import Tkinter
 2  from tkinter.scrolledtext Import ScrolledText
 . 3 the root = tkinter.Tk ()
 . 4 root.title ( ' Towers of Hanoi Solver ' )
 . 5 root.geometry ( ' 300x200 ' )
 . 6 root.resizable (width = False, height = True)
 7 tkinter.Label(root, text= ' Please enter the number of floors of the Tower of Hanoi ' , font=( ' Microsoft Yahei ' , 12 )).pack()
 8 var = tkinter.StringVar()
 9e = tkinter.Entry(root, textvariable = var)
 10  e.pack()
 11 t = tkinter.scrolledtext.ScrolledText(root)
 12 ans = []
 13  def hanoi(n, x, y, z):
 14      if n . 1 == :
 15          ans.append (+ x ' -> ' + Z)
 16      the else :
 . 17         Hanoi (n-1, x, Z, Y) # front n-1 on a plate moves from x to Y 
18 is         ans.append (+ x ' -> ' + Z) # the last tray from the lowermost to move the x Z 
. 19        Hanoi (n-1, y, X, Z) # to the n-1 in the y-plate moves to the Z 
20 is      return ANS
 21 is  DEF Calc ():
 22 is      del ANS [:]
 23 is      n-= int (var.get ( ))
 24      str2 = hanoi(n, ' x ' , ' y ' , ' z ' )
 25      t.delete(0.0 , tkinter.END)
 26      count = 0
 27      for stre in str2:
 28          count = count + 1
 29          t .insert(tkinter.END,' First ' + STR (COUNT) + ' Step: ' + + STRE ' /n- ' )
 30      t.Insert (1.0, ' [total ' + STR (COUNT) + ' Step]/n- ' )
 31 is      t.pack ( )
 32 tkinter.Button(root, text= " OK " , command= calc)
 .pack() 33 root.mainloop()
Frantic Flamingo

Respuestas similares a “Proyecto Simple Tower of Hanoi Python con GUI”

Preguntas similares a “Proyecto Simple Tower of Hanoi Python con GUI”

Más respuestas relacionadas con “Proyecto Simple Tower of Hanoi Python con GUI” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código