File: textlist_demo

package info (click to toggle)
perl-tk 1:804.033-2
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 34,724 kB
  • ctags: 37,174
  • sloc: ansic: 349,541; perl: 52,192; sh: 17,904; makefile: 5,732; asm: 3,565; ada: 1,681; pascal: 1,089; cpp: 1,006; yacc: 883; cs: 879
file content (76 lines) | stat: -rwxr-xr-x 1,597 bytes parent folder | download | duplicates (7)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/local/bin/perl -w

require 5;
use strict;
#use lib qw(/home1/gbartels/textlist);

use Tk;
use Tk::TextList;

my $mw = MainWindow->new;


#my $obj = 'Listbox';
my $obj = 'TextList';

$mw->title($obj);

my @choices = qw
/
alpha bravo charlie delta echo foxtrot golf hotel india juliet kilo
lima mike november oscar papa quebec romea sierra tango uniform victor
wiskey xray yankee zulu
/;


$mw->Label(-text => $obj)->grid(-column => 0, -row => 0);
my $lb = $mw->Scrolled($obj)->grid(-column => 0, -row => 1);
$lb->insert('end', @choices);
$lb->configure(-selectmode=>'extended');

$mw->Label(-text => "Listbox")->grid(-column => 1, -row => 0);
my $lb2 = $mw->Scrolled("Listbox")->grid(-column => 1, -row => 1, -sticky => "ns");
$lb2->insert('end', @choices);
$lb2->configure(-selectmode=>'extended');

 $mw->bind('<F1>',
sub
{
	for my $def ([$lb, $obj],
		     [$lb2, 'Listbox']) {
		print "current selections in $def->[1] are: \n";
		my @list = $def->[0]->curselection;
		print join(' ',@list);
		print "\n\n\n";
	}
});

 $mw->bind('<F2>',
sub
{
	print "current tags are: \n";
	my @list = $lb->tagNames;
	print join(' ',@list);
	print "\n\n\n";
	print "locations are :\n";
	foreach my $tag (@list)
		{
		my @indexes = $lb->tagRanges($tag);
		my $string = join (' ',@indexes);
		print "tag: $tag    locations = $string \n";
		}

$lb->activate(10);
$lb2->activate(10);

});

$lb->tagConfigure('TEST_TAG', foreground=>'red');
$lb->tagAdd('TEST_TAG', 10,13);
$lb->tagAdd('TEST_TAG', 4);
$lb->tagAddChar('TEST_TAG', 1.4, 1.5);

$lb->configure(-width=>20);
$lb2->configure(-width=>20);

MainLoop;