playing with Tkinter, expert needed ?

Matthew Dixon Cowles matt at mondoinfo.com
Sun Apr 14 15:50:02 EDT 2002


On 14 Apr 2002 08:37:42 -0700, J.Jacob <joost_jacob at hotmail.com> wrote:

Dear Joost,

>I have been playing with Tkinter to make a widget that is portable and
>usable from Python version 1.5.2 on.  The widget is for emulation of
>very old-fashioned character based computer screens.

Your project sounds very cool. I don't need it right now but I've
bookmarked it because I'm sure that it will come in handy.

>a) How can I have a 'fat' cursor blinking instead of the small one
>when waiting for input?

There might be a better way to do it but here's what I'd try: first,
hide the vertical bar cursor by setting the text widget's insertwidth
to 0. Then you'll need to create the character-cell cursor. You could
do that by creating a tag that's at the same spot as the automatic
mark "insert" and play with its background and foreground colors. You
could use Tkinter's after() call to change them at appropriate
intervals.

I think the annoying part will be moving the cursor appropriately.
You'd probably want to bind to the <Key> (or perhaps <KeyRelese>)
event.  If Tkinter will let you see "insert" after it has been
updated, you could just move the tag. Otherwise you may have to insert
the characters yourself or predict where Tkinter will move the
insertion point based on the character that the user has typed.  The
after() function may be useful here too.

If you haven't yet run into it, Fredrik Lundh's excellent An
Introduction to Tkinter ought to make doing things like that as
painless as possible. Which is not to say entirely painless. It's at:

http://www.pythonware.com/library/tkinter/introduction/index.htm

Regards,
Matt



More information about the Python-list mailing list