fork download
  1. import tkinter
  2. import random
  3.  
  4. #constant
  5. WIDTH = 640
  6. HEIGHT = 480
  7. BG_COLOR = 'BLUE'
  8.  
  9. #mouse events
  10. def mouse_click(event):
  11. global main_ball
  12. print(event.num, event.x, event.y)
  13. if event.num == 1:
  14. main_ball = Balls(event.x, event.y, 30, 'white')
  15. main_ball.draw()
  16. else:
  17. main_ball.hide()
  18.  
  19.  
  20. #ball class
  21. class Balls():
  22. def __init__(self, x, y, r, color, dx=0, dy=0):
  23. self.x = x
  24. self.y = y
  25. self.color = color
  26. self.r = r
  27. self.dx = dx
  28. self.dy = dy
  29. def draw(self):
  30. canvas.create_oval(self.x - self.r, self.y - self.r, self.x + self.r, self.y + self.r, fill=self.color)
  31. def hide(self):
  32. canvas.create_oval(self.x - self.r, self.y - self.r, self.x + self.r, self.y + self.r, fill=BG_COLOR, outline=BG_COLOR)
  33. def move(self):
  34. self.hide()
  35. self.x += self.dx
  36. self.y += self.dy
  37. self.draw()
  38.  
  39.  
  40.  
  41. #main cicle of game
  42. def main():
  43. if 'main_ball' in globals():
  44. main_ball.move()
  45. root.after(10, main)
  46.  
  47.  
  48. root = tkinter.Tk()
  49. root.title('Dildo')
  50. canvas = tkinter.Canvas(root, width=WIDTH, height=HEIGHT, bg=BG_COLOR)
  51. canvas.pack()
  52. canvas.bind('<Button-1>',mouse_click, '+')
  53. canvas.bind('<Button-2>',mouse_click, '+')
  54. canvas.bind('<Button-3>',mouse_click, '+')
  55. main()
  56. root.mainloop()
Compilation error #stdin compilation error #stdout 0.04s 29272KB
stdin
Standard input is empty
compilation info
Traceback (most recent call last):
  File "/usr/lib/python3.4/py_compile.py", line 124, in compile
    _optimize=optimize)
  File "<frozen importlib._bootstrap>", line 1532, in source_to_code
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "./prog.py", line 45
    root.after(10, main)
                       ^
TabError: inconsistent use of tabs and spaces in indentation

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.4/py_compile.py", line 128, in compile
    raise py_exc
py_compile.PyCompileError: Sorry: TabError: inconsistent use of tabs and spaces in indentation (prog.py, line 45)
stdout
Standard output is empty