Hi monks, I am facing problem with resetting fields.Here I am displaying two radio buttons along with one corresponding values containing one list-box,the problem is that whenever i press reset button the application should reset all the fields like initial state. Can any one please help me how to do it. I have tried with killing the application and re executing it again but it doesn't sounds good for me.

#!/usr/bin/perl -w use Tk; use strict; use warnings; use Tk::LabFrame; use Tk::JPEG; use Tk::PNG; my $mw = MainWindow->new; $mw -> geometry ("400x400+100+120") ; $mw -> CmdLine; my $chk = 0; my @GUI_List; my $var; my $reset; $reset = $mw -> Button(-text => "Reset", -state => 'normal',-command = +> \&reset)->pack(); $reset -> place ( -x => 160, -y => 200 ); my $f1 = $mw -> LabFrame(-label=> "Select one Test",-font=> 'ukai',-la +belside => "acrosstop")->pack(); my $s300 = $f1->Radiobutton(-text=>"TEST1",-value=>"do_1",-indicator=> +1,-variable=>\$chk,-font=>'ukai 11',-command=>\&do_1)->pack(); $s300->configure(-state); my $s310 = $f1->Radiobutton(-text=>"TEST2",-value=>"do_2",-indicator=> +1,-variable=>\$chk,-font=>'ukai',-command=>\&do_2)->pack(); $s310->configure(-state); $f1 -> place ( -x => 40 , -y => 50, -width=>"140", -height => "100" ); my $f2 = $mw -> LabFrame(-label => "Selet One",-font=> 'ukai',-labelsi +de => "acrosstop")->pack(); my @INP_List = (qw/TES0 TES1 TES2 TES3 TES4 TES5 TES6 TES7 TES8 TES9/) +; my $lb = $f2 -> Scrolled("Listbox", -scrollbars => "e",-selectmode => +"extended",-font=> 'ukai',-activestyle => "dotbox")->pack(); $lb -> bind('<Double-1>'=> sub { my $temp = $_[0]->get($_[0]->curselection),; print "$temp\n" }, ); $f2 -> place ( -x => 220 , -y => 50, -width =>"160", -height => "100") +; MainLoop; sub do_1 { if ($chk eq "do_1" ) { $lb->delete(0,'end'); @GUI_List = @INP_List[0,1,2,3,4]; $lb->insert('end',@GUI_List); #print "@GUI_List\n"; } } sub do_2 { if ($chk eq "do_2") { $lb->delete(0,'end'); @GUI_List = @INP_List[5,6,7,8,9]; $lb -> insert('end', @GUI_List); #print "@GUI_List\n"; } } sub reset { $mw->update; }

In reply to How to reset the fields in perl tk by vr786

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.