in reply to Re^2: Using Tk::Text and '<<Modified>>'
in thread Using Tk::Text and '<<Modified>>'

"a consistent interface for all the Tk:: modules."

What is inconsistent here? I agree that it would be much better if they can add some examples here and there in Tk documents, so that we can reach the proper use more quickly. The entire Tk document is long but poor.

But your issue really does not point me to anything that is "inconsistent", but rather some sort of learning curve.

If you want me to point out the inconsistancy, I would say that they better support editModified() in widgets that are really similar to Tk::Text, for example Tk::Entry, but it does not.

use Tk; use Tk::Dialog; use warnings; use strict; my $MW = MainWindow->new(-title => "Tk::Text test", -width => 200, -height => 200); my $text = $MW->Entry( -width => 40); $text->pack(-side => 'top', -fill => 'both'); $text->bind( '<FocusOut>' => \&callback); my $text2 = $MW->Text(-height => 10, -width => 40, -wrap => 'word'); $text2->pack(-side => 'top', -fill => 'both'); MainLoop; sub callback { if ($text->editModified()) { $text->Dialog(-title=>"Modified",-text=>"\$text has been modif +ied")->Show();#or whatever you want $text->editModified(0); } }

Replies are listed 'Best First'.
Re^4: Using Tk::Text and '<<Modified>>'
by castaway (Parson) on Nov 20, 2004 at 19:28 UTC
    Among the modules I am currently using, the methods to get/set their contents, or be notified when they change, vary wildly. Eg:
    • CheckButton -> set a -command callback, and call ->{Value} on it.
    • Entry -> set -validate and -vcmd, do a cget -textvariable and set/retrieve from that
    • BrowseEntry -> -browsecmd, fetch the entry subwidget then as above
    • Button -> -command and cget/configure -text
    • Text -> bind to something (focusout/modified), call -get('0.0', 'end') or somesuch to fetch, Contents() to set
    ... I'm sure I've missed some
    This to me is inconsistent. Why isn't there a 'get()' and 'set()' for all of these, together with a standard callback option to be called when they change? They could still have all their idiocyncraciesspecialities additionally if needed.

    Anyway, this is one of the major arguments that people keep giving me to try and persuade me to switch to some other GUI system, as Tks worst side.. And I keep coming across things that make me agree.

    BTW, I'd prefer Tk::Text be configured more like Tk::Entry and the rest, ie a -command or something on create, instead of the extra bind command, but thats probably just because all the widgets Im currently using also work that way.

    C.