events in wxpython user interfaces to illustrate this we will use simple example we will write very simple event handling application this application will have frame containing panel the panel will contain label using the wx statictext class we will define an event handler called on_mouse_click(that will move the statictext label to the current mouse location when the left mouse button is pressed this means that we can move the label around the screen to do this we first need to determine the widget that will be used to generate the event in this case it is the panel that contains the text label having done this we can look at the panel class to see what events and event bindings it supports it turns out that the panel class only directly defines support for navigationkeyevents this is not actually what we wanthowever the panel class extends the window class the window class supports numerous event bindingsfrom those associated with setting the focus (wx evt_set_focus and wx evt_kill_focusto key presses (wx evt_key_down and wx evt_key_upas well as mouse events there are however numerous different mouse event bindings these allow leftmiddle and right mouse button clicks to be picked updown clicks to be identifiedsituations such as the mouse entering or leaving the window etc howeverthe binding we are interested in for mouseevent is the wx evt_left_down bindingthis picks up on the moueevent when the left mouse button is pressed (there is also the wx evt_left_up binding which can be used to pick up an event that occurs when the left mouse button is releasedwe now know that we need to bind the on_mouse_click(event handler to the mouseevent via the wx evt_left_down event binderfor exampleself panel bind(wx evt_left_downself on_mouse_clickall event handler methods takes two parametersself and the mouse event thus the signature of the on_mouse_click(method isdef on_mouse_click(selfmouse_event)the mouse event object has numerous methods defined that allow information about the mouse to be obtained such as the number of mouse clicks involved (getclickcount())which button was pressed (getbutton()and the current mouse position within the containing widget or window (getposition ()we can therefore use this last method to obtain the current mouse location and then use the setposition(xymethod on the statictext object to set its position the end result is the program shown below