简体   繁体   中英

Python Tkinter Changing the Colour of a Cursor

In my code I'm creating a gui that has various different buttons in it, and I have assigned cursors to each. What I'm wondering is how to change the colour of the cursor from the default white when hovered over these buttons.

B1 = Button(root, text='Delete Recording', bg = col1, cursor = "dotbox", width=15, command=killthat)

When hovered over, this turns the cursor into a dotbox.

I have tried adding colours like so

cursor = "dotbox brown1"

It doesn't produce an error, but it doesn't change the colour either.

Im running on Windows 7 if that helps.

Tkinter supports cursor colors, but it could be that it's not supported on windows 7. I don't have a windows box to test on, but the following creates a green cursor on linux:

import tkinter as tk
root = tk.Tk()
root.configure(cursor="dotbox green")
root.mainloop()

"brown1" may not be a valid color. At least on linux it's not. Have you tried an rgb value (eg: cursor="dotbox #ff0000" )?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM