def start(): draw_board() #Player vs Bot(first) if opponent[0] == "B" and first[0] == "B": bot() turtle.onscreenclick(play) turtle.mainloop()
def alpha_beta_helper(): global state, root, alpha_time initialize() print("PLEASE WAIT!!!") root = TreeNode(-1000) time1 = time.time() alpha_beta(root, 1, state) init_screen() drawLine() drawGrid() drawColumns() drawRows() caliberate() col = root.ans row = -1 turtle.onscreenclick(goto) for i in range(4): if state[i][col] == 0: row = i break state[row][col] = 1 drawDot(row, col, 1) var = (int)(input("Enter 1 to continue playing or 0 to stop.")) time2 = time.time() alpha_time = time2-time1 if(var == 1): turtle.clear() turtle.goto(0, 0) turtle.penup() turtle.right(270) alpha_beta_helper() else: write_analysis(3)
def __init__(self): super(LaserCannon, self).__init__() # Register events. Note the function we register for 'q' is # a turtle function. turtle.onscreenclick(self.aim,1) turtle.onkey(self.shoot,"s") turtle.onkey(seeYaLater,'q')
def main(): tdl.graphicsInit("Boter Kaas en eieren",'white',width,height) #tkMessageBox.showinfo("Introductie", "Welkom bij Boter Kaas en eieren (A.K.A. BKE)") writeToLog("Introductie: Welkom bij Boter Kaas en eieren (A.K.A. BKE)") createGame() writeToLog("Player 1 is about to move.") turtle.onscreenclick(onScreenClickEvent) tdl.done()
def set_mouse_handler(fn): ''' Sets callback function to invoke when the mouse button is pressed. The function is passed the x and y coordinates where the mouse was clicked. Only one mouse handler may be registered at a time. ''' _e.mousefn = fn # XXX turtle.onclick doesn't seem to work here turtle.onscreenclick(_E._mouse_cb)
def draw(): turtle.onscreenclick(None) turtle.color("Blue") turtle.pu() turtle.goto(0,200) turtle.write("Draw",align="center", font=("Futura",30)) turtle.goto(250,-200) turtle.write("(Click anywhere to return to the main menu)",align="right",font=(0.0000001)) turtle.onscreenclick(home) turtle.mainloop()
def engine(): ''' Starts the game engine running. ''' while _e.ithinkican: # flush out changes turtle.update() # delay if it's running too fast time.sleep(_e.delay) # time for random event? for prob, fn in _e.random: if random.random() < prob: fn() # move objects for obj in _e.L: if obj in _e.deleteme: continue obj.step() # note obj may be deleted after calling step() # collision detection # XXX assumes the class of a game object is the class # XXX registered for collisions for i in range(len(_e.L)): obj1 = _e.L[i] if obj1 in _e.deleteme: continue for j in range(i+1, len(_e.L)): obj2 = _e.L[j] if obj2 in _e.deleteme: continue key = (obj1.__class__, obj2.__class__) if key in _e.collide: _e.collide[key](obj1, obj2) if obj1 in _e.deleteme: # may have been deleted post-collision break # handle I/O events for fn, args in _e.ioevents: fn(*args) _e.ioevents = [] # _L quiescent; do deletions _e.L = [obj for obj in _e.L if obj not in _e.deleteme] _e.deleteme.clear() if _e.kbdfn: canvas = turtle.getcanvas() canvas.unbind('<KeyPress>', None) if _e.mousefn: turtle.onscreenclick(None)
def gameover(): turtle.onscreenclick(None) turtle.speed(0) turtle.pu() turtle.goto(0,150) turtle.color("red") turtle.write("Game Over",align="center", font=(10)) turtle.goto(0,50) turtle.write("Score:" + str(a[0]),align="center",font=(10)) turtle.goto(200,-200) turtle.write("(Click anywhere to return to the main menu)",align="right",font=(0.0000001)) turtle.onscreenclick(home) turtle.mainloop()
def winnerp2(): turtle.onscreenclick(None) turtle.pu() turtle.goto(0,200) turtle.color("Green") if opponent[0] == "B" and first[0] == "P": turtle.write("Bot won this game",align="center", font=("Futura",30)) else: turtle.write("Player 2 won this game",align="center", font=("Futura",30)) turtle.goto(250,-200) turtle.write("(Click anywhere to return to the main menu)",align="right",font=(0.0000001)) turtle.onscreenclick(home) turtle.mainloop()
def start(x,y): turtle.onscreenclick(None) level_1() tfood = turtle.Turtle() tfood.hideturtle() tfood.pu() tfood.speed(0) tfood.shape("square") tfood.color("red") tscore = turtle.Turtle() tscore.hideturtle() tscore.pu() tscore.speed(0) tscore.goto(100,-250) tscore.write("Score:" + str(a[0]), align="center",font=(10)) while x > -210 and x < 210 and y > -210 and y <210: if fcoord[2] == 0: food(tfood) fcoord[2] = 1 turtle.onkey(u,"Up") turtle.onkey(l,"Left") turtle.onkey(r,"Right") turtle.onkey(d,"Down") turtle.listen() move() x = turtle.xcor() y = turtle.ycor() if x > fcoord[0]*20-5 and x < fcoord[0]*20+5 and y > fcoord[1]*20-5 and y < fcoord[1]*20+5: fcoord[2] = 0 tfood.clear() a[0] += 1 tscore.clear() tscore.write("Score:" + str(a[0]), align="center",font=(10)) if len(pos) > 1: for i in range(1,len(pos)): if x < pos[i][0]+5 and x > pos[i][0]-5 and y < pos[i][1]+5 and y > pos[i][1]-5: tscore.clear() tfood.clear() gameover() tscore.clear() tfood.clear() gameover()
def home(x,y): x = 0 y = 0 a[0] = 0 b[0] = 0 h[0] = 0 fcoord[2] = 0 pos[:] = [] turtle.hideturtle() turtle.clear() turtle.pu() turtle.color("black") turtle.goto(0,0) turtle.write("Play") turtle.title("Snake") turtle.onscreenclick(start) turtle.mainloop()
def hold(self): """ holds the screen open until the user clicks or types 'q' """ # have the turtle listen for events turtle.listen() # hide the turtle and update the screen turtle.ht() turtle.update() # have the turtle listen for 'q' turtle.onkey( turtle.bye, 'q' ) # have the turtle listen for a click turtle.onscreenclick( lambda x,y: turtle.bye() ) # start the main loop until an event happens, then exit turtle.mainloop() exit()
def home(x,y): #data reset for i in range(3): for j in range(3): board[i][j] = '' n[0] = 0 opponent[0] = '' first[0] = '' b[0] = '' p[0] = '' #menu turtle.hideturtle() turtle.speed(0) turtle.clear() turtle.title("Tic-Tac-Toe") draw_home() turtle.onscreenclick(homeselect) turtle.mainloop()
def main (): current=inputs def draw_current (x,y): print 'CLICK' if not current: exit(0) input=current.pop(0) print 20*'=' print 'before flatten:',input input = list_flatten (input) print 'after flatten:',input # turtle.reset() turtle.speed('fastest') turtle.penup() turtle.goto(x,y) turtle.pendown() for funcall in input: interpret (funcall) draw_current(0,0) turtle.onscreenclick(draw_current) turtle.mainloop()
def set_listeners(self): turtle.onscreenclick(self.clickcb, 1) # In OSX, ctrl-click doesn't give a button-3 click. Instead, # trackpad users have to enable secondary click in system # preferences. Then, right-clicking on trackpad generates a # button-2 click. I don't know what one-button mouse users can # do? turtle.onscreenclick(self.rightclickcb, 2) # On Linux, right-click generates a button-3 click. turtle.onscreenclick(self.rightclickcb, 3) turtle.onkey(self.spacecb, "space") turtle.onkey(self.savecb, "s") turtle.onkey(self.redisplaycb, "r") turtle.listen()
t.begin_fill() t.circle(50) t.end_fill() # Left Eye t.setpos(x-15, y+60) t.fillcolor('blue') t.begin_fill() t.circle(10) t.end_fill() # Right Eye t.setpos(x+15, y+60) t.begin_fill() t.circle(10) t.end_fill() # Mouth t.setpos(x-25,y+40) t.pencolor('black') t.width(10) t.goto(x-10, y+20) t.goto(x+10, y+20) t.goto(x+25, y+40) t.width(0) def draw_kaleido(x,y): draw_smiley(x,y) draw_smiley(-x,y) draw_smiley(-x,-y) draw_smiley(x,-y) turtle.onscreenclick(draw_kaleido)
def reset_first_click(self): turtle.onscreenclick(self.first)
def go_right(): '''Moves turtle right on screen when right arrow is pressed''' turtle.setheading(0) fd(10) def go_left(): '''Moves turtle left on screen when left arrow is pressed''' turtle.setheading(180) fd(10) def go_down(): '''Moves turtle down on screen when down arrow is pressed''' turtle.setheading(270) fd(10) def stampit(eks,why): '''moved the turtle to the position on the screen that was clicked and stamps itself''' pu() turtle.goto(eks,why) turtle.stamp() pd() #Global Turtle ready to... run begin() turtle.bgcolor('black') hello() turtle.getscreen().listen() #allows us to collect key events to move turtle, but window must be active window. turtle.onscreenclick(stampit) turtle.mainloop()
turtle.color(color) turtle.penup() turtle.goto(x,y) turtle.pendown() turtle.circle(20) turtle.end_fill() turtle.penup() def circle(x,y): global color draw_circle(color,x,y) turtle.getscreen().onkeypress(color_red,"r") turtle.getscreen().onkeypress(color_black,"b") turtle.getscreen().onkeypress(color_purple,"p") turtle.onscreenclick(circle) #turtle.onscreenclick(blue_circle,btn=3) #draw_circle("blue",70,20) def draw_square(color,x,y): turtle.penup() turtle.goto(x,y) turtle.begin_fill() turtle.color(color) turtle.pendown() turtle.goto(x+50,y) turtle.goto(x+50,y+50) turtle.goto(x,y+50) turtle.end_fill()
def main(): display_help_window() scr = turtle.Screen() turtle.colormode('standard') xsize, ysize = scr.screensize() turtle.setworldcoordinates(0, 0, xsize, ysize) turtle.hideturtle() turtle.speed('fastest') turtle.tracer(0, 0) turtle.penup() board = LifeBoard(xsize // CELL_SIZE, 1 + ysize // CELL_SIZE) def toggle(x, y): cellx = x // CELL_SIZE celly = y // CELL_SIZE if board.is_legal(cellx, celly): board.toggle(cellx, celly) board.display() turtle.onscreenclick(turtle.listen) turtle.onscreenclick(toggle) board.makeRandom() board.display() def erase(): board.erase() board.display() turtle.onkey(erase, 'e') def makeRandom(): board.makeRandom() board.display() turtle.onkey(makeRandom, 'r') turtle.onkey(sys.exit, 'q') continuous = False def step_once(): nonlocal continuous #continuous variable but a new one not the same scope continuous = False perform_step() def step_continuous(): nonlocal continuous continuous = True perform_step() def perform_step(): board.step() board.display() if continuous: turtle.ontimer(perform_step, 1) turtle.onkey(step_once, 's') turtle.onkey(step_continuous, 'c') def up_size(): global CELL_SIZE CELL_SIZE += 1 makeRandom() def down_size(): global CELL_SIZE CELL_SIZE -= 1 makeRandom() turtle.onkey(up_size, '+') turtle.onkey(down_size, '-') turtle.listen() turtle.mainloop()
turtle.shape("turtle") #stamp 2 def stamp2(x,y): turtle.penup() turtle.goto(x,y) turtle.pendown() turtle.goto(x,y+20) turtle.goto(x+20,y) turtle.goto(x-20,y) turtle.goto(x,y+20) #when clicked, post stamp. turtle.onscreenclick(stamp2, btn=1 , add= True) turtle.onscreenclick(stamp1, btn =3 ,add=True) #clear def clear(): turtle.clear() #COLOR CHANGING def Switch_color1(): turtle.color("red") def Switch_color2(): turtle.color("blue") #when pressing O, change color turtle.getscreen().onkeypress(Switch_color2,"o") #press p = change color turtle.getscreen().onkeypress(Switch_color1, "p")
def onClick(self, mX, mY): turtle.onscreenclick(None) self.turn(self.curPlayer, mX, mY) turtle.onscreenclick(self.onClick)
elif(-50 <= x <= 50 and -150 <= y <= -50): # Square 8 if (boxes[8] == 'empty'): player[0](-45,-55) boxes[8] = player[1] else: num_moves_made -= 1 elif(50 <= x <= 150 and -150 <= y <= -50): # Square 9 if (boxes[9] == 'empty'): player[0](55,-55) boxes[9] = player[1] else: num_moves_made -= 1 for i in range (8): if (boxes[win_ans[i][0]] == player[1] and boxes[win_ans[i][1]] == player[1] and boxes[win_ans[i][2]] == player[1]): winner = True rachel.penup() rachel.goto(-240, 160) rachel.pendown() rachel.write(player[1] + ' is the winner!!!', font=('Arial', 45, 'normal')) if ('empty' not in boxes.values() and winner == False): rachel.penup() rachel.goto(-145, 145) rachel.pendown() rachel.write('Draw!', font=('Arial', 30, 'normal')) turtle.onscreenclick(draw_symbol) turtle.mainloop() # Wait for user to close window
sc.tracer(False) x_scale = length y_scale = breadth time = 0 time_inc = speed show_time = 1 time_ratio = update_after_iterations #ratio = 3.43 x = x_scale * math.sin(ratio * time + s_phase) y = y_scale * math.cos(time + c_phase) t.penup() t.goto(x, y) t.pendown() # t.goto(100,100) i = 0 while (max_updates): # print("In while") time += time_inc x = x_scale * math.sin(ratio * time + s_phase) y = y_scale * math.cos(time + c_phase) t.goto(x, y) i += 1 # sc.update() if i % time_ratio == 0: # print("Updating") max_updates -= 1 sc.update() turtle.onscreenclick(Lissajous) turtle.mainloop()
# alternate : turtle, twist and octo size contexts = ((caroline, 15, 100, ), (chloe, 60, 30 ), (bob, 40, 60 ), ) # initialize alternating contexts cycle = len(contexts) counter = -1 # the callback triggered when a user clicks in x,y def clicked(x, y): global counter counter += 1 # alternate between the various contexts (turtle, twist, size) = contexts[counter % cycle] turtle.penup() turtle.goto(x, y) turtle.pendown() turtle.left(twist) octo(turtle, size) # arm callback turtle.onscreenclick(clicked) # user can quit by typing 'q' turtle.onkey(turtle.bye, 'q') turtle.listen() # read & dispatch events turtle.mainloop()
def run_turtles(): """ Reads the log file and commands turtles to move or write based on each line of the log. """ global last_message, last_options, last_size, last_len, i, guess_counter log = open('comm.log', 'r') messages = [line[:-1] for line in list(log)] t.ht() draw_gallows() last_message, last_options, last_size, last_len, i, guess_counter = '', '', '', 6, 0, 0 normal_font, bold_font = ('Times New Roman', 24, 'normal'), ('Times New Roman', 24, 'bold') # Displaying "Initializing" message. t.penup() t.setpos((0, 400)) t.write(messages[0], align='center', font=normal_font) t.setpos((0, 375)) init_str = "Your word is " + ( messages[1].split(' ')[3][:-1]) + ", but I can't see that." t.write(init_str, align='center', font=normal_font) t.penup() t.setpos((0, -100)) t.write('Ready!', align='center', font=('Times New Roman', 30, 'bold')) t.setpos((0, -225)) t.write('Guessed Letters', align='center', font=bold_font) def clickme(x, y): global last_message, last_options, last_size, last_len, i, guess_counter # Clearing the "Ready!" t.penup() t.setpos((0, -100)) over_write('Ready!', align='center', font=('Times New Roman', 30, 'bold')) # Every click advances line by line until it reaches a new turn. while (True): i += 1 if (i == len(messages)): # I don't know how to kill this thing short of sys.exit() sys.exit() if re.match('turns: ', messages[i]): # Writing "Ready!" at the end of each turn. t.penup() t.setpos((0, -100)) t.write('Ready!', align='center', font=('Times New Roman', 30, 'bold')) return if re.match('dict_size: ', messages[i]): # Show Number of Words Left t.penup() t.setpos((-450, 275)) over_write(last_size, align='left', font=normal_font) write_str = 'Words to Choose From: ' + str( re.search('\d+', messages[i]).group()) t.write(write_str, font=normal_font) last_size = write_str if re.match('Success!', messages[i]): # Clear Last Options t.setpos((-450, 200)) for j in range(1, last_len): overwrite_str = "My #" + str(j) + " guess: " + eval( last_options[14:])[j - 1].upper() if j == 1: over_write(overwrite_str, align='left', font=bold_font) else: over_write(overwrite_str, align='left', font=normal_font) t.setpos((-450, (200 - j * 25))) # Draw Smile draw_body(10) t.setpos((250, 325)) t.write('I won! Want to play again?', align='center', font=('Times New Roman', 22, 'bold')) return if re.match('Current word: ', messages[i]): # Updating Current Word t.setpos((250, -50)) over_write(last_message, align='center', font=('Times New Roman', 22, 'bold')) t.write(messages[i], align='center', font=('Times New Roman', 22, 'bold')) last_message = messages[i] if re.match('Best Options: ', messages[i]): t.penup() t.setpos((-450, 200)) options_length = len(eval(messages[i][14:])) + 1 # Clearing Last Options for j in range(1, last_len): if last_options == '': break overwrite_str = "My #" + str(j) + " guess: " + eval( last_options[14:])[j - 1].upper() if j == 1: over_write(overwrite_str, align='left', font=bold_font) else: over_write(overwrite_str, align='left', font=normal_font) t.setpos((-450, (200 - j * 25))) t.setpos((-450, 200)) # Write Current Options for j in range(1, options_length): write_str = "My #" + str(j) + " guess: " + eval( messages[i][14:])[j - 1].upper() if j == 1: t.write(write_str, font=bold_font) else: t.write(write_str, font=normal_font) t.setpos((-450, (200 - j * 25))) last_options, last_len = messages[i], options_length if re.match('Guessed Letter: ', messages[i]): # Adds guessed words to bin at the bottom. guess_letter = re.search('\w$', messages[i]).group().upper() xspacing = list(range(-300, 300, 23)) t.penup() t.setpos((xspacing[guess_counter], -300)) if (guess_letter not in messages[1].split(' ')[3][:-1]): t.pencolor('red') t.write(guess_letter, align='center', font=normal_font) t.pencolor('black') else: t.write(guess_letter, align='center', font=normal_font) guess_counter += 1 if re.match('wrongs: ', messages[i]): # Update the Hangman wrong = int(re.search('\d+', messages[i]).group()) draw_body(wrong) if wrong == 9: t.setpos((250, 325)) t.write('I lost! Want to play again?', align='center', font=('Times New Roman', 22, 'bold')) i = len( messages) - 1 # triggers sys.exit() in next iteration. return t.onscreenclick(clickme)
turtle.getscreen().onkeypress(yellow_color,"y") turtle.getscreen().listen() def orange_color(): turtle.color("#FF800D") turtle.getscreen().onkeypress(orange_color,"o") turtle.getscreen().listen() def clear(): turtle.clear() turtle.getscreen().onkeypress(clear,"c") turtle.getscreen().listen() turtle.color("black") turtle.shape("circle") def stamp(x,y): turtle.ht() turtle.penup() turtle.goto(x,y) turtle.pendown() turtle.stamp() turtle.onscreenclick(stamp, btn=1, add=True) turtle.mainloop()
def onClick(self, mX, mY): turtle.onscreenclick(None) self.turn(-2 * (self.count % 2) + 1, mX, mY) turtle.onscreenclick(self.onClick)
def reset_second_click(self): turtle.onscreenclick(self.second)
turtle.pencolor("fuchsia") def color_turquoise(): turtle.pencolor("turquoise") def clear(): turtle.clear() turtle.getscreen().onkeypress(color_fuchsia,"f") turtle.getscreen().listen() turtle.getscreen().onkeypress(color_turquoise,"t") turtle.getscreen().listen() turtle.getscreen().onkeypress(clear,"c") turtle.getscreen().listen() turtle.onscreenclick(meet,btn=1,add=True) turtle.onscreenclick(MEET,btn=3,add=True) turtle.mainloop
def main(): display_help_window() scr = turtle.Screen() turtle.mode('standard') xsize, ysize = scr.screensize() turtle.setworldcoordinates(0, 0, xsize, ysize) turtle.hideturtle() turtle.speed('fastest') turtle.tracer(0, 0) turtle.penup() board = LifeBoard(xsize // CELL_SIZE, 1 + ysize // CELL_SIZE) # Set up mouse bindings def toggle(x, y): cell_x = x // CELL_SIZE cell_y = y // CELL_SIZE if board.is_legal(cell_x, cell_y): board.toggle(cell_x, cell_y) board.display() turtle.onscreenclick(turtle.listen) turtle.onscreenclick(toggle) board.makeRandom() board.display() # Set up key bindings def erase(): board.erase() board.display() turtle.onkey(erase, 'e') def makeRandom(): board.makeRandom() board.display() turtle.onkey(makeRandom, 'r') turtle.onkey(sys.exit, 'q') # Set up keys for performing generation steps, either one-at-a-time or not. continuous = False def step_once(): nonlocal continuous continuous = False perform_step() def step_continuous(): nonlocal continuous continuous = True perform_step() def perform_step(): board.step() board.display() # In continuous mode, we set a timer to display another generation # after 25 millisenconds. if continuous: turtle.ontimer(perform_step, 25) turtle.onkey(step_once, 's') turtle.onkey(step_continuous, 'c') # Enter the Tk main loop turtle.listen() turtle.mainloop()
def Bigger(): global size size=size+10 def Smaller(): global size size=size-10 turtle.getscreen().onkeypress(finish,"e") turtle.getscreen().onkeypress(switch,"s"or"S") turtle.getscreen().onkeypress(color,"c"or"C") turtle.getscreen().onkeypress(Bigger,"8") turtle.getscreen().onkeypress(Smaller,"9") turtle.ondrag(draw,1,add=True) turtle.onscreenclick(draw) turtle.pu() turtle.getscreen().listen() turtle.mainloop()
turtle.pencolor("blue" or "red" or "pink" or "green" or "yellow" or "brown" or "black") def change_color_blue(): turtle.pencolor("blue") turtle.color("blue") def change_color_white(): turtle.pencolor("black") turtle.color("white") turtle.pensize(100) turtle.onkeypress(change_color_red, "r") turtle.onkeypress(change_color_blue, "b") turtle.onkeypress(change_color_white, "w") turtle.onkeypress(change_color_random, "k") turtle.onscreenclick(draw_square, btn=3) turtle.onscreenclick(draw_circle, add=True) turtle.ondrag(turtle.goto, add=True) turtle.ondrag(turtle.goto, btn=3, add=True) turtle.pencolor("blue") turtle.color("blue")
def main(): turtle.tracer(0, 0) turtle.hideturtle() turtle.onscreenclick(clickhandler) draw_board(the_board) turtle.mainloop()
import turtle t = turtle.Pen() t.speed(0) turtle.bgcolor("blue") t.pencolor("green") t.width(99) while True: turtle.onscreenclick(t.setpos)
align="center", font=("Arial", 12, "bold")) w.ht() elif color_B == color_A: w.clear() w.penup() w.goto(0, -300) w.pendown() w.write( "\"It's against the rules if both teams have the same color\"", align="center", font=("Arial", 15, "bold")) w.ht() w.penup() w.goto(0, -320) w.pendown() w.write("(MAKE SURE THAT BOTH TEAMS HAVE UNIQUE COLOR)", align="center", font=("Arial", 12, "bold")) w.ht() else: sound.Menu_Play(1) clear() #starting the game import Start turtle.listen() turtle.onscreenclick(Check, 1) turtle.done()
h = turtle.window_height() if t.ycor() < h/2 - 10: t.seth(90) t.forward(10) def paint(): t.pendown() def dont_paint(): t.penup() def spin(x, y): t.left(2*360) t.right(2*360) t.onclick(spin) turtle.onscreenclick(move) turtle.onkey(move_right, 'Right') turtle.onkey(move_left, 'Left') turtle.onkey(move_up, 'Up') turtle.onkey(move_down, 'Down') turtle.onkey(paint, 'U') turtle.onkey(dont_paint, 'D') turtle.listen()
garo.onkey(down, 's') garo.onkey(left, 'a') garo.onkey(right, 'd') garo.onkey(upper_left, 'q') garo.onkey(lower_left, 'z') garo.onkey(upper_right, 'e') garo.onkey(lower_right, 'c') garo.onkey(home, 'x') # Pen up, Pen down, garo.onkey(penup, '1') garo.onkey(pendown, '2') # Begin fill, End fill garo.onkey(beginfill, '3') garo.onkey(endfill, '4') garo.onscreenclick(clickmiddle, 2) garo.onscreenclick(clickleft, 1) garo.onscreenclick(clickright, 3) garo.onkey(screencolor, '5') garo.onkey(screen_undo, '6') garo.onkey(screen_clear, '7') garo.onkey(exit, "o") # Program Loop garo.mainloop() # exit = garo.mainloop(False)