Tkinter is a standard Python library for developing GUI-based applications. We can change the properties of its widgets by using the built-in functions and methods. In some applications, the properties affect the mouse pointer as well.
Tkinter provides us a way to change the mouse pointer color in the window. To configure the mouse pointer color, we can specify the cursor value with (cursor type and its color). For example, to change the cursor color in a label widget, we can specify the value as, cursor="plus #aab1212" where "plus" defines the cursor type and #aab1212 is the Hex value of the color.
# Import the required libraries from tkinter import * # Create an instance of tkinter frame or window win=Tk() # Set the size of the window win.geometry("700x350") # Add bottom widget label=Label(win, text="label cursor", cursor="plus red", font=('calibri 18')) label.pack(pady=20) Button(win, text="Button cursor",cursor="dot blue").pack() win.mainloop()
If we run the above code, it will display a window with a label widget and a button. Hovering on the widget will change the cursor property.