turtle.onscreenclick() function in Python Last Updated : 26 Jul, 2020 Comments Improve Suggest changes Like Article Like Report The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses Tkinter for the underlying graphics, it needs a version of Python installed with Tk support. turtle.onscreenclick() This function is used to bind fun to a mouse-click event on canvas. Syntax : turtle.onscreenclick(fun, btn=1, add=None) Parameters: Arguments Description funa function with two arguments, the coordinates of the clicked point on the canvas.btnnumber of the mouse-button defaults to 1 (left mouse button)addTrue or False. If True, new binding will be added, otherwise it will replace a former binding Below is the implementation of the above method with an example : Python3 # import packages import turtle import random # global colors col = ['red', 'yellow', 'green', 'blue', 'white', 'black', 'orange', 'pink'] # method to call on screen click def fxn(x, y): global col ind = random.randint(0, 7) # set screen color randomly sc.bgcolor(col[ind]) # set screen sc = turtle.Screen() sc.setup(400, 300) # call method on screen click turtle.onscreenclick(fxn) Output : Here we can find that whenever the user clicks (yellow-colored dot on arrow) on screen it changes the background color of the turtle graphics window randomly. Comment More infoAdvertise with us Next Article Company-wise Practice Problems D deepanshu_rustagi Follow Improve Article Tags : Python Python-turtle Practice Tags : python Similar Reads Interview PreparationInterview Preparation For Software DevelopersMust Coding Questions - Company-wise Must Do Coding Questions - Topic-wiseCompany-wise Practice ProblemsCompany PreparationCompetitive ProgrammingSoftware Design-PatternsCompany-wise Interview ExperienceExperienced - Interview ExperiencesInternship - Interview ExperiencesPractice @GeeksforgeeksProblem of the DayTopic-wise PracticeDifficulty Level - SchoolDifficulty Level - BasicDifficulty Level - EasyDifficulty Level - MediumDifficulty Level - HardLeaderboard !!Explore More...Data StructuresArraysLinked ListStackQueueBinary TreeBinary Search TreeHeapHashingGraphAdvance Data StructuresMatrixStringAll Data StructuresAlgorithmsAnalysis of AlgorithmsSearching AlgorithmsSorting AlgorithmsPattern SearchingGeometric AlgorithmsMathematical AlgorithmsRandomized AlgorithmsGreedy AlgorithmsDynamic ProgrammingDivide & ConquerBacktrackingBranch & BoundAll AlgorithmsProgramming LanguagesCC++JavaPythonC#Go LangSQLPHPScalaPerlKotlinWeb TechnologiesHTMLCSSJavaScriptBootstrapTailwind CSSAngularJSReactJSjQueryNodeJSPHPWeb DesignWeb BrowserFile FormatsComputer Science SubjectsOperating SystemsDBMSComputer NetworkComputer Organization & ArchitectureTOCCompiler DesignDigital Elec. & Logic DesignSoftware EngineeringEngineering MathematicsData Science & MLComplete Data Science CourseData Science TutorialMachine Learning TutorialDeep Learning TutorialNLP TutorialMachine Learning ProjectsData Analysis TutorialTutorial LibraryPython TutorialDjango TutorialPandas TutorialKivy TutorialTkinter TutorialOpenCV TutorialSelenium TutorialGATE CSGATE CS NotesGate CornerPrevious Year GATE PapersLast Minute Notes (LMNs)Important Topic For GATE CSGATE CoursePrevious Year Paper: CS exams Like