Tkinter md5 problem
Dagur Páll Ammendrup
dagurp at heimsnet.is
Sat Dec 28 07:57:20 EST 2002
Hi!
In the Introduction to Tkinter I found this method to detect if the
contents in a Text widget have changed:
---------------------------------------------------
import md5
def getsignature(contents):
return md5.md5(contents).digest()
text.insert(END, contents) # original contents
signature = getsignature(contents)
...
contents = text.get(1.0, END)
if signature != getsignature(contents):
print "contents have changed!"
---------------------------------------------------
This does work, but only if you're using ASCII, otherwise you get a
UnicodeError
UnicodeError: ASCII encoding error: ordinal not in range(128)
So what can I do?
Thanks in advance!
-Dagur
More information about the Python-list
mailing list