Advertisement
Guest User

turtle graphics

a guest
Feb 6th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. from turtle import* # do and val are inputs for the function
  2. from tkinter import*
  3. x = 6
  4. reset()
  5. def TC (do,val): #So TC is the function name - needs to be called when running the program
  6. do = do.upper() #converts all to CAPITAL letters
  7. if do =='F':
  8. forward(val) # Turns a do value of F into turtle command forward
  9. elif do == 'B':
  10. backward(val)
  11. elif do == 'R':
  12. right(val)
  13. elif do == 'L':
  14. left(val)
  15. elif do == 'U':
  16. penup()
  17. elif do == 'D':
  18. pendown()
  19. elif do == 'N':
  20. reset()
  21.  
  22. else:
  23.  
  24. print('Duds command, you lump!')
  25.  
  26.  
  27. def fAction():
  28. TC('f',i)
  29. def bAction():
  30. TC('b',i)
  31. def rAction():
  32. TC('r',i)
  33. def lAction():
  34. TC('l',i)
  35. def uAction():
  36. TC('u',i)
  37. def dAction():
  38. TC('d',i)
  39. def nAction():
  40. TC('n',i)
  41.  
  42. window = Tk()
  43.  
  44. buttonF = Button(window, text="Forward", command=fAction)
  45. buttonB = Button(window, text="Backward", command=bAction)
  46. buttonR = Button(window, text="Right", command=rAction)
  47. buttonL = Button(window, text="Left", command=lAction)
  48. buttonU = Button(window, text="Penup", command=uAction)
  49. buttonD = Button(window, text="Pendown", command=dAction)
  50. buttonN = Button(window, text="Reset", command=nAction)
  51.  
  52. L1 = Label(window, text="Value")
  53. L1.pack(side = LEFT)
  54. E1 = Entry(window, bd =5)
  55. E1.pack(side = RIGHT)
  56. buttonF.pack()
  57. buttonB.pack()
  58. buttonR.pack()
  59. buttonL.pack()
  60. buttonU.pack()
  61. buttonD.pack()
  62. buttonN.pack()
  63. if x>5:
  64. i = E1.get()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement