in reply to reseting text widget
I think what you're asking for is how to delete the contents of a Text widget.
That's easy ... use the delete method. For example:
$txtapitimhsh -> delete('1.0', 'end');
The above code means to delete from the first line, zeroth character ('1.0') to the end of the Text widget (which can, of course, be multiple lines long).
Here's your program with a few corrections made so that it would run, and with use strict; and use warnings; (which are usually a good idea ;-)):
use strict; use warnings; use Tk; my @totalmetoxwn = ( ); my $telikitimh = 100; my $sunolometoxwn = 0; my $mw = new MainWindow; my $frm_name3 = $mw -> Frame() -> pack(); my $frm_name4 = $mw -> Frame() -> pack(); my $addbutton = $frm_name3 -> Button(-text => "Prosthesi", -command =>\&push_button); $addbutton->pack(-side=>'left'); my $txtapitimhsh = $frm_name4 -> Text(-width=>8, -height=>1); $txtapitimhsh -> pack(-side=>'right'); MainLoop; sub push_button { @totalmetoxwn = ( ); push(@totalmetoxwn, $telikitimh); foreach (@totalmetoxwn) { $sunolometoxwn += $_ ; #here i get the previous value and the new one $txtapitimhsh -> delete('1.0', 'end'); $txtapitimhsh -> insert('end', $sunolometoxwn); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: reseting text widget
by Anonymous Monk on Dec 13, 2006 at 07:34 UTC |