Ma************@gmail.com writes:
Tkinter definitely deserves more respect! I'm making rapid progress
and it looks good.
But am stuck on this: I want the File/Save state to change from
disabled to enabled, depending on whether or not there is something to
save (Text modified). Google returns results in every language except
Python.
Sub problems: how to change state of menu item? how to detect changes
in Text widget?
Help appreciated.
State of menu items can be changed like this:
<code>
import Tkinter as Tk
def hello():
if mfile.entrycget(2, 'state') == 'disabled':
state = 'normal'
else:
state = 'disabled'
mfile.entryconfigure(2, state=state)
root = Tk.Tk()
menubar = Tk.Menu(root)
mfile = Tk.Menu(menubar)
mfile.add_command(label="Open", command=hello)
mfile.add_command(label="Save", command=hello)
menubar.add_cascade(label='File', menu=mfile)
root.config(menu=menubar)
root.mainloop()
</code>
But I think that you should read this:
http://effbot.org/zone/vroom.htm
HTH,
Rob