Thread TK::Compound: Wie setze ich eine Hintergrundfarbe? (10 answers)
Opened by Robby at 2004-02-18 14:14

havi
 2004-02-18 14:27
#41612 #41612
User since
2003-08-04
2036 Artikel
BenutzerIn
[Homepage]
user image
Schau mal hier

Code: (dl )
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
#! /usr/local/bin/perl -w

require 5.005;

use strict;
use English;

use Tk;

# Create main window with button and text widget in it...
my $top = MainWindow->new;
my $btn = $top->Button(-text=>'print odd lines')->pack;
my $txt = $top->Scrolled('Text', -relief=>'sunken', -borderwidth=>'2',
-setgrid=>'true', -height=>'30', -scrollbars=>'e');
$txt->pack(-expand=>'yes', -fill=>'both');
$btn->configure(-command=>sub{&GetText($txt)} );

# Populate text widget with lines tagged odd and even...
my $lno;
my $oddeven;
foreach $lno (1..20) {
if($lno % 2) { $oddeven = "odd" } else { $oddeven = "even" };
$lno = "Line $lno ($oddeven)\n";
$txt->insert ('end', $lno, $oddeven);
}

# Do the main processing loop...
MainLoop();

sub GetText {
my $txtobj = shift;

$txtobj->tag('configure', 'odd', -background=>'lightblue');
$txtobj->tag('configure', 'even', -background=>'lightgreen');

# This is the goal of all the work...
my @lines = $txtobj->get($txtobj->tagRanges('odd'));

print STDERR join("", @lines);
}


Gruss

View full thread TK::Compound: Wie setze ich eine Hintergrundfarbe?