Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. from tkinter import *
  2.  
  3. def checkered(canvas, line_distance):
  4. for x in range(line_distance,canvas_width,line_distance):
  5. canvas.create_line(x, 0, x, canvas_height, fill="#476042")
  6. for y in range(line_distance,canvas_height,line_distance):
  7. canvas.create_line(0, y, canvas_width, y, fill="#476042")
  8. ###############################################################################
  9. root = Tk()
  10. canvas_width = 1000
  11. canvas_height = 760
  12. w = Canvas(root,
  13. width=canvas_width,
  14. height=canvas_height)
  15. checkered(w,20)
  16. w.pack()
  17.  
  18. a = int(canvas_height / 2)
  19. w.create_line(0, a, canvas_width, a,
  20. fill="black",width=3)
  21. b = int(canvas_width / 2)
  22. w.create_line(b, 0, b,canvas_height,
  23. fill = "red",width=3)
  24. w.create_text(5, ((canvas_height/2)-10)
  25. ,text="x",font=12)
  26. w.create_text(b+10 ,5
  27. ,text='y',font=12)
  28. w.create_text(b+10,a-10
  29. ,text='0',font=12)
  30. w.create_oval(b-5,a-5,b+5,a+5
  31. ,fill = 'black')
  32. w=int(canvas_width/50)
  33. z=int(canvas_width/100)
  34. aa=b+w
  35. bb=a-z
  36. cc=a+z
  37. w.create_line(aa,bb,aa,cc,
  38. fill='black',width=3)
  39.  
  40. mainloop()
  41.  
  42. line 37, in <module>
  43. builtins.AttributeError: 'int' object has no attribute 'create_line'
  44.  
  45. a = int(canvas_height / 2)
  46. w.create_line(0, a, canvas_width, a,
  47. fill="black",width=3)
  48.  
  49. b = int(canvas_width / 2)
  50. w.create_line(b, 0, b,canvas_height,
  51. fill = "red",width=3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement