Tkinter: Entry widget with history/completion

Hans-Joachim Widmaier hjwidmai at foxboro.com
Tue Jun 13 01:12:01 EDT 2000


I'd like to have an Entry(-like) widget that has a history
and a completion mechanism. I see no problems doing the first
one, but I see no convenient way to do the latter, as I cannot
find any widget method that gives me the current index of the
cursor (my aim is to complete the phrase from index 0 upto the
cursor position, ignoring what is right to it). Did I miss
something? I certainly don't want to write a whole new widget,
just use Entry and extend it.

How would you recommend doing it?
 - By subclassing Entry
 - By creating a new Pmw MegaWidget

Both of them look like nice implementations to me.

I have another question that bothers me since long, just out of
curiosity.

The geometry manager methods on widgets [pack(), grid(), place()]
return None. To reduce the number of lines of code (which is
considered A Good Thing), wouldn't it be nice to be able to
write
  
  e = Entry().pack()

instead of

  e = Entry()
  e.pack()

I guess there is a reason for those methods to not return 'self'.
I just can't think of any ...

Thanks for any help,
-- 
Hans-Joachim Widmaier




More information about the Python-list mailing list