Setting cursor colors in tkinter

Eric Brunel eric.brunel at pragmadev.com
Fri Sep 20 10:43:45 EDT 2002


Edward K. Ream wrote:
> Hi,
> 
> I would like to set the foreground an background colors of a cursor.
> 
> Following:
> 
> http://www.tcl.tk/man/tcl8.3/TkLib/GetCursor.htm#M4
> 
> I am synthesizing a cursor description with
> 
> cursor="xterm " + fg + " " + bg
> 
> yielding, e.g.,
> 
> cursor = "xterm red green"
> 
> I then call:
> 
> body.configure(cursor=cursor)
> 
> However, Tcl complains:
> 
>     self.tk.call((self._w, 'configure')
> TclError: bad cursor spec "xterm red green"
> 
> Can anyone say how this should properly be done?  Put another way, I may
> be asking what the proper format of
> 
> "name [fgColor [bgColor]]"
> 
> is in the URL above.

What platform are you on? On Linux, doing:

from Tkinter import *
root = Tk()
root.configure(cursor='xterm red green')

doesn't produce an error. The colours seem to to be taken into account, but 
the xterm cursor isn't really a good example. I tried 
root.configure(cursor='gumby red green') and the result was what I expected.

Maybe there are some issues on Windows?
-- 
- Eric Brunel <eric.brunel at pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com



More information about the Python-list mailing list