I'm a newbie python/tkinter programmer! I am displaying a text widget for the user to use as a barebones editor.
Is it possible to check if the user modified it in any way, so that I know if it necessary a savef开发者_开发百科ile step?
thanks!
alessandro
The easiest thing to do would be to use the Text.edit_modified()
method. A simple usage example:
>>> import Tkinter
>>> root = Tkinter.Tk()
>>> frame = Tkinter.Frame(root)
>>> text = Tkinter.Text(frame)
>>> text.pack()
>>> frame.pack()
>>> text.edit_modified()
0
>>> text.insert('1.0', 'some text')
>>> text.edit_modified()
1
>>> text.edit_modified(False)
''
>>> text.edit_modified()
0
精彩评论