The command $widget -> create type options is used to make different structures A few examples are given
below For more information read the manual
Example
#!/usr/local/bin/perl
use Tk;
# Main Window
my $mw = new MainWindow;
my $cns = $mw -> Canvas(-relief=>"sunken", -background=>"blue");
$cns -> create('polygon',5,100,50,5,150,5,200,100,5,100,
-joinstyle=>"bevel", -fill=>"red", -outline=>"white", -width=>5);
$cns -> create('oval',200,100,300,200, -fill=>"green");
$cns -> create('oval',100,150,300,100, -fill=>"white", -width=>0);
$cns -> create('rectangle',10,150,100,250, -dash=>[6,4,2,4,2,4]);
$cns -> pack;
MainLoop;
#!/usr/local/bin/perl
use Tk;
# Main Window
my $mw = new MainWindow;
my $cns = $mw -> Canvas(-relief=>"xxx", -background=>"blue");
$cns -> create('polygon',5,100,50,5,150,5,200,100,5,100,
-joinstyle=>"bevel", -fill=>"red", -outline=>"white", -width=>5);
$cns -> create('oval',200,100,300,200, -fill=>"green");
$cns -> create('oval',100,150,300,100, -fill=>"white", -width=>0);
$cns -> create('rectangle',10,150,100,250, -dash=>[6,4,2,4,2,4]);
$cns -> pack;
MainLoop;
-relief=>"xxx":
bad relief type "xxx": must be flat, groove, raised, ridge, solid, or sunken at
C:/Perl/site/lib/Tk/Widget.pm line 205.
at tx.pl line 5.
polygon 多边形
oval 椭圆形
rectangle 矩形