File: canvas_scroll

package info (click to toggle)
perl-tk 1:800.025-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 18,444 kB
  • ctags: 19,081
  • sloc: ansic: 206,740; perl: 40,187; makefile: 4,371; sh: 2,373; yacc: 762
file content (44 lines) | stat: -rwxr-xr-x 1,006 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/local/bin/perl -w

use Tk;

$top = MainWindow->new();

$top->wm("minsize",  10, 10);
$top->wm("geometry", "100x100");

$c = $top->Canvas("-width" => 200,"-height" => 200);


$s1 = $top->Scrollbar("-command" => ["yview",$c]);
$s2 = $top->Scrollbar("-orient" => "horizontal",
                           "-command" => ["xview",$c]);
$c->configure("-yscrollcommand" => ["set",$s1]);
$c->configure("-xscrollcommand" => ["set",$s2]);


$id = $c->create("line",0,0, 0,200, 200,0, 200,200, 0,0, 200,0, 200,200, 0,200,
                 "-width" => 4);

print "Line id=$id\n";

$id = $c->create("grid",0,0, 10,10,"-width" => 1);

print "Grid id=$id\n";

$c->create("grid",0,0, 50,50,"-width" => 1, -lines => 1, -dash => '.');
$c->create("grid",0,0, 100,100,"-width" => 1, -lines => 1);


$c->configure("-scrollregion" => [0,0,204,204]);


$s1->pack( "-side"   => "left", "-fill"   => "y");
$s2->pack(  "-side"   => "bottom", "-fill"   => "x");
$c->pack("-expand" => 1, "-fill" => "both" );


Tk::MainLoop;