[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Tkinter: Missing the last piece of the puzzle

Martin Rinehart

2/23/2008 5:00:00 PM

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.)
3 Answers

Simon Forman

2/24/2008 3:45:00 AM

0

On Feb 23, 9:00 am, MartinRineh...@gmail.com wrote:
> 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?

yes! check out http://aspn.activestate.com/ASPN/Cookbook/Python/Rec...

HTH,
~Simon

> 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.)


Martin Rinehart

2/24/2008 10:17:00 AM

0



Simon Forman wrote:
> yes! check out http://aspn.activestate.com/ASPN/Cookbook/Python/Rec...
>
> HTH,
> ~Simon

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.

Russell E. Owen

2/27/2008 8:39:00 PM

0

In article
<c558d504-9162-4e6e-be5a-fd7334e90375@p43g2000hsc.googlegroups.com>,
MartinRinehart@gmail.com wrote:

> Simon Forman wrote:
> > yes! check out
> > http://aspn.activestate.com/ASPN/Cookbook/Python/Rec...
> >
> > HTH,
> > ~Simon
>
> 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