Search code examples
pythontkintermouse-cursor

How to get the current cursor type, color and size in Python Tkinter?


Is there any way to get the current cursor type in Python Tkinter? For example "fleur"? Also, is there any method to get the current cursor color and the cursor size? Thanks in advance :)


Solution

  • From what I understand, yes:

    Note: insertbackground sets the color of a cursor.

    from tkinter import *
    from tkinter import ttk
    root=Tk()
    entry1=Entry(root,cursor="fleur",insertbackground="red")
    entry1.pack()
    Button(root,text="Get cursor type and colour", command=lambda: print(entry1['cursor'],entry1['insertbackground'])).pack()
    root.mainloop()