1#!/usr/local/bin/perl -w
2
3require 5;
4use strict;
5#use lib qw(/home1/gbartels/textlist);
6
7use Tk;
8use Tk::TextList;
9
10my $mw = MainWindow->new;
11
12
13#my $obj = 'Listbox';
14my $obj = 'TextList';
15
16$mw->title($obj);
17
18my @choices = qw
19/
20alpha bravo charlie delta echo foxtrot golf hotel india juliet kilo
21lima mike november oscar papa quebec romea sierra tango uniform victor
22wiskey xray yankee zulu
23/;
24
25
26$mw->Label(-text => $obj)->grid(-column => 0, -row => 0);
27my $lb = $mw->Scrolled($obj)->grid(-column => 0, -row => 1);
28$lb->insert('end', @choices);
29$lb->configure(-selectmode=>'extended');
30
31$mw->Label(-text => "Listbox")->grid(-column => 1, -row => 0);
32my $lb2 = $mw->Scrolled("Listbox")->grid(-column => 1, -row => 1, -sticky => "ns");
33$lb2->insert('end', @choices);
34$lb2->configure(-selectmode=>'extended');
35
36 $mw->bind('<F1>',
37sub
38{
39	for my $def ([$lb, $obj],
40		     [$lb2, 'Listbox']) {
41		print "current selections in $def->[1] are: \n";
42		my @list = $def->[0]->curselection;
43		print join(' ',@list);
44		print "\n\n\n";
45	}
46});
47
48 $mw->bind('<F2>',
49sub
50{
51	print "current tags are: \n";
52	my @list = $lb->tagNames;
53	print join(' ',@list);
54	print "\n\n\n";
55	print "locations are :\n";
56	foreach my $tag (@list)
57		{
58		my @indexes = $lb->tagRanges($tag);
59		my $string = join (' ',@indexes);
60		print "tag: $tag    locations = $string \n";
61		}
62
63$lb->activate(10);
64$lb2->activate(10);
65
66});
67
68$lb->tagConfigure('TEST_TAG', foreground=>'red');
69$lb->tagAdd('TEST_TAG', 10,13);
70$lb->tagAdd('TEST_TAG', 4);
71$lb->tagAddChar('TEST_TAG', 1.4, 1.5);
72
73$lb->configure(-width=>20);
74$lb2->configure(-width=>20);
75
76MainLoop;
77