K
king
#!\c\perl\bin
use Tk;
my $mw = new MainWindow; # Main Window
my $frm_name = $mw -> Frame() -> pack();
my $lab = $frm_name -> Label(-text=>"Name:") -> pack();
my $ent = $frm_name -> Entry() -> pack();
my $but = $mw -> Button(-text=>"Push Me", -command =>\&push_button) ->
pack();
#Text Area
my $txt = $mw -> Text(-width=>50, -height=>30) -> pack();
MainLoop;
#This function will be executed when the button is pushed
sub push_button {
my $name = $ent -> get();
$txt -> insert('end',"Hello, $name.");
}
1.as soon as i run this script
a window opens
But the cursor is not on the name block
Question- Can it be possible that as soon as the window opens the
cursor should be present in the name block.
again
2. suppose once i typed a name,it will show up with hellow then the
$name.
but in the same window if I again give some other name in the name
block,
the hellow $ name is coming next to the previous test messege in the
text area.
Question
Each time I give a input and then enter button push me the only text
present there should be hellow and the recent name entered.
Can it be possible to do that.
use Tk;
my $mw = new MainWindow; # Main Window
my $frm_name = $mw -> Frame() -> pack();
my $lab = $frm_name -> Label(-text=>"Name:") -> pack();
my $ent = $frm_name -> Entry() -> pack();
my $but = $mw -> Button(-text=>"Push Me", -command =>\&push_button) ->
pack();
#Text Area
my $txt = $mw -> Text(-width=>50, -height=>30) -> pack();
MainLoop;
#This function will be executed when the button is pushed
sub push_button {
my $name = $ent -> get();
$txt -> insert('end',"Hello, $name.");
}
1.as soon as i run this script
a window opens
But the cursor is not on the name block
Question- Can it be possible that as soon as the window opens the
cursor should be present in the name block.
again
2. suppose once i typed a name,it will show up with hellow then the
$name.
but in the same window if I again give some other name in the name
block,
the hellow $ name is coming next to the previous test messege in the
text area.
Question
Each time I give a input and then enter button push me the only text
present there should be hellow and the recent name entered.
Can it be possible to do that.