Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

simple tower of hanoi project python with 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()
Comment

simple tower of hanoi project python with 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()
Comment

PREVIOUS NEXT
Code Example
Python :: jenkins crumb python request 
Python :: how to take input as an integer in python 
Python :: mock connection sqlalchemy 
Python :: gensim prepare corpus 
Python :: penggunaan keys di python 
Python :: Use PIP from inside script 
Python :: call a Python range() using range(stop) 
Python :: python call c function 
Python :: python to dart converter 
Python :: How to set a tkinter window to a constant size 
Python :: send message in every channel discord.py 
Python :: map reduce and filter functions in python 
Python :: browser environment: 
Python :: changing labels of facetgrid 
Python :: Permission error 
Python :: HTML default value fo radio button input type based on python variable 
Python :: Converting Data Types 
Python :: tdlib python 
Python :: python for loop skip iteration if condition not met jinja 
Python :: ring Using Lists during definition 
Python :: text to ascii art generator python 
Python :: ring Desktop, WebAssembly and Mobile create an application to ask the user about his/her name. 
Python :: python quick tutorial 
Python :: how to ge squrre root symobl as string inpython 
Python :: python durchschnitt liste 
Python :: get picamera feed 
Python :: Quiver Simple Demo 
Python :: vaibhav=complex(2,5) 
Python :: orm odoo 
Python :: how to incorportate a different language in python code 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =