Tkinter: Missing the last piece of the puzzle

M

MartinRinehart

I have a simple editor built into my visual parser. It has a File menu
with
typical New, Open, Save, Save As ... options. I now know how to set
the options [en/dis]abled and how to check the Text widget's modified
flag.

Now I want to [en/dis]able those options. Can I ask the text to notify
me when the modified flag changes? Can I set the statuses when the
user clicks File, before the options are displayed? Do I need to
create
a checker on an independent thread that looks at the flag every few
millis?

(Tkinter deserves more respect. I've got a good-looking application
growing quickly.)
 
M

MartinRinehart

Simon said:

Thanks, Simon. Looks like that will do it.

Actually, it looks like that will overdo it. I'll be setting File/Save
to enabled after every keystroke. Ideally, I'd like to set my statuses
when the user clicks the File option or types Alt-F. This makes me
wonder if there's a "mixin" that could find this event. Hmmm.

Alternatively, could modify this code to NOT reset the modified flag,
so I only get called on the first modification. Hmmm.
 
R

Russell E. Owen

Thanks, Simon. Looks like that will do it.

Actually, it looks like that will overdo it. I'll be setting File/Save
to enabled after every keystroke. Ideally, I'd like to set my statuses
when the user clicks the File option or types Alt-F. This makes me
wonder if there's a "mixin" that could find this event. Hmmm.

Set an internal state variables "isChanged" based on the Text callback
and only modify the menu if the variable is set.

It's trickier to detect "significant" changes vs insigificant ones.
Personally I would not bother to go that far.

-- Russell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,438
Messages
2,571,699
Members
48,796
Latest member
Greg L.
Top