Yurttas/PL/SL/perl/F/11/00/02/checkbuttons 01.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_01.pl
14#
15
16
17use Tk;
18
19sub chosen() {
20  print "select : y|n\n";
21  print "choose Colors button\n";
22}
23
24sub color_choice() {
25  print "the color is : ";
26  print "red" if $red;
27  print "green" if $green;
28  print "blue" if $blue;
29  print "\n";
30}
31
32my $mw = MainWindow->new;
33
34$mw->title("sy - checkbuttons-01");
35
36$mw->Button(-text     => "color_choice",
37            -command  => \&color_choice) ->pack;
38
39$mw->Checkbutton(-text     => "red",
40                 -command  => \&chosen,
41                 -variable => \&red) ->pack;
42
43$mw->Checkbutton(-text     => "green",
44                 -command  => \&chosen,
45                 -variable => \&green) ->pack;
46
47$mw->Checkbutton(-text     => "blue",
48                 -command  => \&colors,
49                 -variable => \&blue) ->pack;
50
51MainLoop;