Re: Tkinter Menu Item Activation



MartinRinehart@xxxxxxxxx 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

.



Relevant Pages

  • Re: Garmin 2610 vs. 2620
    ... >> you are stuck with what you have. ... > Also, depending on how you plan on using the unit, I've heard that the ... Unless you are computer illiterate and can't figure out ...
    (sci.geo.satellite-nav)
  • Re: BIG DVD PROBLEM!!
    ... video. ... Depending on what else is being stuck on the disk that figure ...
    (rec.video.dvd.tech)
  • Tkinter Menu Item Activation
    ... Tkinter definitely deserves more respect! ... I'm making rapid progress ... But am stuck on this: I want the File/Save state to change from ...
    (comp.lang.python)
  • Re: What do you want in season 3?
    ... universe being stuck with concepts that seemed like a good ... depending on the age of the franchise in question). ...
    (rec.arts.drwho.moderated)
  • Re: AAAARRRGGGHHH
    ... if it's for work then I guess you're stuck. ... Uh, yeah, there is, but fortunately or un, depending on the mood of the ...
    (sci.med.transcription)