Change text in a Text (TextField) in radio button and checkbox button action : Text « GUI « Perl






Change text in a Text (TextField) in radio button and checkbox button action

   

use Tk;

$main = MainWindow->new();

$main->Radiobutton( -text => "Radio 1",
    -command => sub{
    $text1->delete('1.0', 'end');
    $text1->insert('end', "You clicked radio 1");}
)->pack;

$main->Radiobutton( -text => "Radio 2",
    -value => "0",
    -command => sub{
    $text1->delete('1.0', 'end');
    $text1->insert('end', "You clicked radio 2");
    }
)->pack;

$main->Checkbutton( -text => "Check 1",
    -command => sub{
    $text1->delete('1.0', 'end');
    $text1->insert('end', "You clicked check 1");
    }
)->pack;

$main->Checkbutton( -text => "Check 2",
    -command => sub{
    $text1->delete('1.0', 'end');
    $text1->insert('end', "You clicked check 2");
    }
)->pack;

$text1 = $main->Text ('-width'=> 40, '-height' => 2)->pack;

MainLoop;

   
    
    
  








Related examples in the same category

1.Bind mouse double click action to a Text control
2.Call Text insert function to add text to a Text control
3.Insert text to a Text control (TextField)
4.Set width and height of a Text
5.Use the Scrolled to control the scroll of a Text Entry
6.Configure a Text Widget
7.Create a scrolled Text widget
8.Entry(text field): Set highlightthickness
9.Entry(text field): set font
10.Fill the Entry (text field): textvariable
11.Get text input in a single line Text Box
12.Insert bold text to a Text widget
13.Insert text string to a Text Widget
14.Mark text in a Scrolled Text Widget
15.Auto-scroll entry (text field)
16.Single-Line Text Entry