use strict; use warnings; use Tk; use Tk::Radiobutton; my $mw = Tk::MainWindow->new; my $rb_value; # undef, no Radiobutton selected $mw->Radiobutton(-text=>'first',-value=>'one',-variable=>\$rb_value)->pack(-anchor=>'w'); $mw->Radiobutton(-text=>'second',-value=>'one',-variable=>\$rb_value)->pack(-anchor=>'w'); $mw->Radiobutton(-text=>'third',-value=>'three',-variable=>\$rb_value)->pack(-anchor=>'w'); $mw->Label(-text=>'------------------------')->pack; my $other_value = '0000ff'; # preset blue $mw->Radiobutton(-text=>'RED',-value=>'ff0000',-variable=>\$other_value)->pack(-anchor=>'w'); $mw->Radiobutton(-text=>'GREEN',-value=>'00ff00',-variable=>\$other_value)->pack(-anchor=>'w'); $mw->Radiobutton(-text=>'BLUE',-value=>'0000ff',-variable=>\$other_value)->pack(-anchor=>'w'); MainLoop; print 'rb:',$rb_value,$/; print 'other:',$other_value,$/;