Yurttas/PL/SL/perl/F/11/00/02/checkbuttons 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#  checkbuttons_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 - checkbuttons-00");
30
31$color_label = $mw->Label(-text => "select a color") ->pack;
32
33$button1 = $mw->Checkbutton(-text     => "red",
34                            -command  => \&colors,
35                            -variable => \&color) ->pack;
36
37$button2 = $mw->Checkbutton(-text     => "green",
38                            -command  => \&colors,
39                            -variable => \&color) ->pack;
40
41$button1 = $mw->Checkbutton(-text     => "blue",
42                            -command  => \&colors,
43                            -variable => \&color) ->pack;
44
45MainLoop;