Yurttas/PL/SL/perl/F/11/00/02/radiobuttons 00.pl

From ZCubes Wiki
Jump to navigation Jump to search
 1#
 2#  Copyright(C) 2003
 3#  All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4#
 5#  Permission from use, copy, modify, and distribute this
 6#  software and its documentation for EDUCATIONAL purposes
 7#  and without fee is hereby granted provided that this
 8#  copyright notice appears in all copies.
 9#
10#  date   : January 1, 2003.
11#  author : Salih Yurttas.
12#
13#  radiobuttons_00.pl
14#
15
16
17use Tk;
18
19sub colors() {
20  %colors = { 1 => 'red',
21              2 => 'green',
22              3 => 'blue'
23            };
24  print "$colors{$color}\n";
25}
26
27my $mw = MainWindow->new;
28
29$mw->title("sy - radiobuttons-00");
30
31$color_label = $mw->Label(-text => "select a color") ->pack;
32
33$button1 = $mw->Radiobutton(-text     => "red",
34                            -value    => 1,
35                            -command  => \&colors,
36                            -variable => \&color) ->pack;
37
38$button2 = $mw->Radiobutton(-text     => "green",
39                            -value    => 2,
40                            -command  => \&colors,
41                            -variable => \&color) ->pack;
42
43$button1 = $mw->Radiobutton(-text     => "blue",
44                            -value    => 3,
45                            -command  => \&colors,
46                            -variable => \&color) ->pack;
47
48MainLoop;