in reply to TK form submission

use Tk; my $top = new MainWindow; my $but = $top->Button(text=>"OK", command=>\&get_text)->pack; my $tex = $top->Text()->pack; MainLoop; sub get_text { $text = $tex->get(0.1,'end'); print $text; }

Replies are listed 'Best First'.
Re^2: TK form submission
by Anonymous Monk on Jun 06, 2004 at 20:02 UTC
    Can you explain what $text = $tex->get(0.1,'end'); is? I mean, what is get(0.1,'end') ?

    Thanks!

      It should be "1.0" instead of "0.1" and it means: get the whole contents of the text widget, that is from line 1 column 0 to the end.
      characters in a Text widget are referenced by text indexes. The parameters of the get method are the start index and stop index (which is optional). Indexes are denoted in line.character format. Line numbers in a Text widget start at 1, and characters on a line start at 0. end is a special index referring to the end of the widget or line. So, for example:

      my $text = $widget->get("2.0", "5.end")

      means get everything from line 2, character 1 to the end of line 5 and place the content into the variable $text.

      For a more detailed explanation, refer to O'reilly's "Mastering Perl/Tk." If you are writing gui's in Perl/Tk it is a most valuable resource.

      hope this helps,
      davidj