Tkinter: Missing the last piece of the puzzle

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MartinRinehart@gmail.com

    Tkinter: Missing the last piece of the puzzle

    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.)
  • Simon Forman

    #2
    Re: Tkinter: Missing the last piece of the puzzle

    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/Coo.../Recipe/464635

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

    Comment

    • MartinRinehart@gmail.com

      #3
      Re: Tkinter: Missing the last piece of the puzzle



      Simon Forman wrote: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.

      Comment

      • Russell E. Owen

        #4
        Re: Tkinter: Missing the last piece of the puzzle

        In article
        <c558d504-9162-4e6e-be5a-fd7334e90375@p4 3g2000hsc.googl egroups.com>,
        MartinRinehart@ gmail.com wrote:
        Simon Forman wrote:>
        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 "significan t" changes vs insigificant ones.
        Personally I would not bother to go that far.

        -- Russell

        Comment

        Working...