Debian Codegraph @

examples/canvas_scroll

raw
1 #!/usr/local/bin/perl -w
2
3 use Tk;
4
5 $top = MainWindow->new();
6
7 $top->wm("minsize", 10, 10);
8 $top->wm("geometry", "100x100");
9
10 $c = $top->Canvas("-width" => 200,"-height" => 200);
11
12
13 $s1 = $top->Scrollbar("-command" => ["yview",$c]);
14 $s2 = $top->Scrollbar("-orient" => "horizontal",
15 "-command" => ["xview",$c]);
16 $c->configure("-yscrollcommand" => ["set",$s1]);
17 $c->configure("-xscrollcommand" => ["set",$s2]);
18
19
20 $id = $c->create("line",0,0, 0,200, 200,0, 200,200, 0,0, 200,0, 200,200, 0,200,
21 "-width" => 4);
22
23 print "Line id=$id\n";
24
25 $id = $c->create("grid",0,0, 10,10,"-width" => 1);
26
27 print "Grid id=$id\n";
28
29 $c->create("grid",0,0, 50,50,"-width" => 1, -lines => 1, -dash => '.');
30 $c->create("grid",0,0, 100,100,"-width" => 1, -lines => 1);
31
32
33 $c->configure("-scrollregion" => [0,0,204,204]);
34
35
36 $s1->pack( "-side" => "left", "-fill" => "y");
37 $s2->pack( "-side" => "bottom", "-fill" => "x");
38 $c->pack("-expand" => 1, "-fill" => "both" );
39
40
41 Tk::MainLoop;
42
43
44