import tkinter
import random
#constant
WIDTH = 640
HEIGHT = 480
BG_COLOR = 'BLUE'
#mouse events
def mouse_click( event) :
global main_ball
print ( event.num , event.x , event.y )
if event.num == 1 :
main_ball = Balls( event.x , event.y , 30 , 'white' )
main_ball.draw ( )
else :
main_ball.hide ( )
#ball class
class Balls( ) :
def __init__ ( self , x, y, r, color, dx= 0 , dy= 0 ) :
self .x = x
self .y = y
self .color = color
self .r = r
self .dx = dx
self .dy = dy
def draw( self ) :
canvas.create_oval ( self .x - self .r , self .y - self .r , self .x + self .r , self .y + self .r , fill= self .color )
def hide( self ) :
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)
def move( self ) :
self .hide ( )
self .x += self .dx
self .y += self .dy
self .draw ( )
#main cicle of game
def main( ) :
if 'main_ball' in globals ( ) :
main_ball.move ( )
root.after ( 10 , main)
root = tkinter.Tk ( )
root.title ( 'Dildo' )
canvas = tkinter.Canvas ( root, width= WIDTH, height= HEIGHT, bg= BG_COLOR)
canvas.pack ( )
canvas.bind ( '<Button-1>' , mouse_click, '+' )
canvas.bind ( '<Button-2>' , mouse_click, '+' )
canvas.bind ( '<Button-3>' , mouse_click, '+' )
main( )
root.mainloop ( )
aW1wb3J0IHRraW50ZXIKaW1wb3J0IHJhbmRvbQoKI2NvbnN0YW50CldJRFRIID0gNjQwCkhFSUdIVCA9IDQ4MApCR19DT0xPUiA9ICdCTFVFJwoKI21vdXNlIGV2ZW50cwpkZWYgbW91c2VfY2xpY2soZXZlbnQpOgogICAgZ2xvYmFsIG1haW5fYmFsbAogICAgcHJpbnQoZXZlbnQubnVtLCBldmVudC54LCBldmVudC55KQogICAgaWYgZXZlbnQubnVtID09IDE6CiAgICAgICAgbWFpbl9iYWxsID0gQmFsbHMoZXZlbnQueCwgZXZlbnQueSwgMzAsICd3aGl0ZScpCiAgICAgICAgbWFpbl9iYWxsLmRyYXcoKQogICAgZWxzZToKICAgICAgICBtYWluX2J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W50ZXIuQ2FudmFzKHJvb3QsIHdpZHRoPVdJRFRILCBoZWlnaHQ9SEVJR0hULCBiZz1CR19DT0xPUikKY2FudmFzLnBhY2soKQpjYW52YXMuYmluZCgnPEJ1dHRvbi0xPicsbW91c2VfY2xpY2ssICcrJykKY2FudmFzLmJpbmQoJzxCdXR0b24tMj4nLG1vdXNlX2NsaWNrLCAnKycpCmNhbnZhcy5iaW5kKCc8QnV0dG9uLTM+Jyxtb3VzZV9jbGljaywgJysnKQptYWluKCkKcm9vdC5tYWlubG9vcCgp
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