Msg.config(bg='lightgreen', font=('times', 24, 'italic'))Įvery time we move the mouse in the Message widget, the position of the mouse pointer will be printed. Msg = Message(master, text = whatever_you_do) Whatever_you_do = "Whatever you do will be insignificant, but it is very important that you do Print("Mouse position: (%s %s)" % (event.x, event.y)) if the mouse is moved inside of a widget: Let's have another simple example, which shows how to use the motion event, i.e. Widget = Button(None, text='Mouse Clicks') # write tkinter as Tkinter to be Python 2.x compatible If the defined event occurs in the widget, the "handler" function is called with an event object. For each widget, it's possible to bind Python functions and methods to an event. Tkinter provides a mechanism to let the programmer deal with events. Events can be key presses or mouse operations by the user. A Tkinter application runs most of its time inside an event loop, which is entered via the mainloop method.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |