: Requires that the given event happens three times in quick succession : Requires that the given event happens twice in quick succession (such as a double click) : Requires that caps lock is activated when the event occurs. : Requires that the shift button is being pressed while the event is occurring. : Requires that the alt button is being pressed while the event is occurring. : Requires that the control button is being pressed while the event is occurring. : Activated when the designated widget's configurations have changes such as its width being adjusted by the user or its border being adjusted.Īn event modifier can alter the circumstances in which an event's handler is activated, for example, some modifiers will require another button to be depressed while the event occurs. : Activated when the designated widget loses focus. : Activated when the designated widget gains focus through user input such as the mouse clicking on it. : Activated when the mouse wheel is scrolled. : Activated when the mouse cursor leaves the designated widget. : Activated when the mouse cursor enters the designated widget. : Activated when the mouse cursor moves across the designated widget. : Activated when a mouse button has been released. : Activated when a mouse button has been clicked. : Activated when a keyboard button is released.
: Activated when a keyboard button has been pressed, the There are several event types available with Tkinter, including:
#Python tkinter icursor example code
The above code will create a window with a single label with the text "click me", when any of the mouse buttons are clicked (left click, right click or middle mouse button click) the mouseClick() function will be called and will print "mouse clicked" to the console. Label = Label( window, text= "Click me" ) The function included as the event handler will be passed an event object which includes details about the event that was triggered, meaning you should include a parameter to be assigned this object in your function.Īs an example, let's assign an event handler to a mouse click event on a label that will print a message when activated: This is only the name of the function, meaning you cannot include a list of your own arguments. : The name of the function to call when the event occurs. The only required part of this string is the "type" section, this represents the type of event to listen for, if you leave out the other section it can be written as "".
: A representative string that contains details about which event to listen for, this must be given in the following format: To bind an event with a function, we can make use of the bind() function that is included in all widgets.
In Python, using the Tkinter GUI package, we can handle these events by binding them to either predefined or user-defined functions, this allows us to run pieces of code when a certain event occurs within a widget. In programming, an event is something that occurs within an application's environment such as a mouse click, key press or changes in the GUI.