Discussion:
[Tkinter-discuss] Autocomplete example on wiki
python
2011-06-23 12:18:28 UTC
Permalink
I'm looking for a way to add autocomplete functionality to my
Windows based Tkinter applications running under Python 2.7
(32-bit).

I've started by using code found on the wiki, but I'm open to
other suggestions as well. Ideally I'd like a solution that works
with the ttk.Entry widget.

Here's the link to the wiki's auto-complete widget that I'm
trying to get to work.
[1]http://tkinter.unpythonic.net/wiki/AutocompleteEntry

When I run the code on this page, I receive the following
traceback:

C:\test>py27 tkautocomplete.py
Type a 't' to test the AutocompleteEntry widget.
Will use AutocompleteEntry.set_completion_list((u'test', u'type',
u'true', u'tre
e', u'time'))
Try also the backspace key and the arrow keys.
Traceback (most recent call last):
File "tkautocomplete.py", line 99, in <module>
test(test_list)
File "tkautocomplete.py", line 89, in test
entry.set_completion_list(test_list)
File "tkautocomplete.py", line 35, in set_completion_list
self.bind('<KeyRelease>', self.handle_keyrelease)
AttributeError: AutocompleteEntry instance has no attribute
'handle_keyrelease'

The traceback complains about a missing handle_keyrelease
attribute which is present in the sample code.

I'm using the 32-bit version of Python 2.7 for Windows under
Windows 7 Professional.

Thank you,
Malcolm

References

1. http://tkinter.unpythonic.net/wiki/AutocompleteEntry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20110623/b263be53/attachment.html>
Michael O'Donnell
2011-06-24 13:24:14 UTC
Permalink
Hi,

Tried the code here on Windows 7 using Python 2.7.1,
no problem at all.

Given that the method handle_keyrelease is explicitly defined
in the code at http://tkinter.unpythonic.net/wiki/AutocompleteEntry,
my guess is that you have modified the code somehow such that
it doesn't work, or changed indentation, or....

Can you send me the code you are running, and I will check it out?

Mick
I'm looking for a way to add autocomplete functionality to my Windows based
Tkinter applications running under Python 2.7 (32-bit).
I've started by using code found on the wiki, but I'm open to other
suggestions as well. Ideally I'd like a solution that works with the
ttk.Entry widget.
Here's the link to the wiki's auto-complete widget that I'm trying to get to
work.
http://tkinter.unpythonic.net/wiki/AutocompleteEntry
C:\test>py27 tkautocomplete.py
Type a 't' to test the AutocompleteEntry widget.
Will use AutocompleteEntry.set_completion_list((u'test', u'type', u'true',
u'tre
e', u'time'))
Try also the backspace key and the arrow keys.
? File "tkautocomplete.py", line 99, in <module>
??? test(test_list)
? File "tkautocomplete.py", line 89, in test
??? entry.set_completion_list(test_list)
? File "tkautocomplete.py", line 35, in set_completion_list
??? self.bind('<KeyRelease>', self.handle_keyrelease)
AttributeError: AutocompleteEntry instance has no attribute
'handle_keyrelease'
The traceback complains about a missing handle_keyrelease attribute which is
present in the sample code.
I'm using the 32-bit version of Python 2.7 for Windows under Windows 7
Professional.
Thank you,
Malcolm
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss at python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Michael O'Donnell
2011-06-24 18:17:15 UTC
Permalink
Dear Malcom,

Having looked at your version of the code, I see that
the method: def handle_keyrelease(self, event)
is indented one tab too far.

If you are in Idle, select all of the method, and select
"Dedent Region" from the Format menu. Then it should work.

Mick


On Fri, Jun 24, 2011 at 3:24 PM, Michael O'Donnell
Hi,
?Tried the code here on Windows 7 using Python 2.7.1,
no problem at all.
Given that the method handle_keyrelease is explicitly defined
in the code at http://tkinter.unpythonic.net/wiki/AutocompleteEntry,
my guess is that you have modified the code somehow such that
it doesn't work, or changed indentation, or....
Can you send me the code you are running, and I will check it out?
Mick
I'm looking for a way to add autocomplete functionality to my Windows based
Tkinter applications running under Python 2.7 (32-bit).
I've started by using code found on the wiki, but I'm open to other
suggestions as well. Ideally I'd like a solution that works with the
ttk.Entry widget.
Here's the link to the wiki's auto-complete widget that I'm trying to get to
work.
http://tkinter.unpythonic.net/wiki/AutocompleteEntry
C:\test>py27 tkautocomplete.py
Type a 't' to test the AutocompleteEntry widget.
Will use AutocompleteEntry.set_completion_list((u'test', u'type', u'true',
u'tre
e', u'time'))
Try also the backspace key and the arrow keys.
? File "tkautocomplete.py", line 99, in <module>
??? test(test_list)
? File "tkautocomplete.py", line 89, in test
??? entry.set_completion_list(test_list)
? File "tkautocomplete.py", line 35, in set_completion_list
??? self.bind('<KeyRelease>', self.handle_keyrelease)
AttributeError: AutocompleteEntry instance has no attribute
'handle_keyrelease'
The traceback complains about a missing handle_keyrelease attribute which is
present in the sample code.
I'm using the 32-bit version of Python 2.7 for Windows under Windows 7
Professional.
Thank you,
Malcolm
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss at python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
python
2011-06-25 16:57:26 UTC
Permalink
Dear Mick,
Having looked at your version of the code, I see that the method: def handle_keyrelease(self, event)
is indented one tab too far.

Thank you for taking the time to uncover the problem in my code.

<embarassed> I can't believe I missed that indentation error!
</embarrassed>

Thanks again!
Malcolm

Loading...