word for it (or run this on your ownbut the main point of this example is to demonstrate other kinds of event binding protocols at work we saw script that intercepted left and double-left mouse clicks with the widget bind method in using event names and the script here demonstrates other kinds of events that are commonly caught with bindto catch the press of single key on the keyboardregister handler for the event identifierthis is lower-level way to input data in gui programs than the entry widget covered in the next section the key pressed is returned in ascii string form in the event object passed to the callback handler (event charother attributes in the event structure identify the key pressed in lower-level detail key presses can be intercepted by the top-level root window widget or by widget that has been assigned keyboard focus with the focus method used by this script this script also catches mouse motion while button is held downthe registered event handler is called every time the mouse is moved while the left button is pressed and receives the current / coordinates of the mouse pointer in its event argument (event xevent ysuch information can be used to implement object movesdrag-and-droppixel-level paintingand so on ( see the pydraw examples in this script also catches right and middle mouse button clicks (known as buttons and to make the middle button click work on two-button mousetry clicking both buttons at the same timeif that doesn' workcheck your mouse setting in your properties interface (the control panel on windowsto catch more specific kinds of key pressesthis script registers for the returnenter and up-arrow key press eventsthese events would otherwise be routed to the general handler and require event analysis here is what shows up in the stdout output stream after left clickright clickleft click and draga few key pressesa return and up-arrow pressand final double-left click to exit when you press the left mouse button and drag it around on the displayyou'll get lots of drag event messagesone is printed for every move during the drag (and one python callback is run for each) :\pp \gui\tourpython bind py got left mouse button clickwidget = = got right mouse button clickwidget = = got left mouse button clickwidget = = got left mouse button dragwidget = = got left mouse button dragwidget = = binding events