Thread Button bei event ausgrauen/disablen (11 answers)
Opened by Gast at 2007-12-13 16:20

styx-cc
 2007-12-14 13:16
#103875 #103875
User since
2006-05-20
533 Artikel
BenutzerIn

user image
Nicht besonders schoen, aber es funktioniert =)

Code (perl): (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
#!/usr/bin/perl -w
use strict;
use Tk;

my $mw = tkinit();
my @werte = qw(1 2 3 4 5 6);
my $listbox = $mw->Scrolled('Listbox',
                           -scrollbars => 'e',
                           -height => 5,
                           -listvariable => \@werte, -exportselection => 1,)
                 ->pack(-side => 'left', -fill => 'y',);
$listbox->bind('<<ListboxSelect>>', sub{check_state()} );

my $b1 = $mw->Button(-text => 'test')->pack;

my $lb2 = $mw->Scrolled('Listbox',
                        -scrollbars => 'e',
                        -height => 5,
                        -listvariable => \@werte,)
             ->pack(-side => 'left', -fill => 'y',);
$lb2->bind('<<ListboxSelect>>', sub{check_state()});

MainLoop;

sub check_state {
  if ($listbox->curselection()) {
    $b1->configure( -state => "normal");
  } else {
    $b1->configure( -state => "disabled" );
  }
}


MfG
Pörl.

View full thread Button bei event ausgrauen/disablen