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

Gast Gast
 2007-12-17 10:36
#103970 #103970
Ok, hab hier kurz was zusammen gestellt

(zum testen einfach einmal start drücken, eintrag anwählen, dann stop drücken, und dann wieder start)


Teil 1 (2. teil einfach darunter einfuegen)

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
32
33
34
#!/usr/bin/perl
use strict;
use warnings;
use Tk;

my $mw = new MainWindow(-title =>"Test");
my $windowheight = 360;
my $windowwidth = 470;
my $mframe = $mw->Frame();
my $textfield1 = $mframe->ScrlListbox(-scrollbars =>"se", -height => 10, -width => 35);
my $button_start = $mframe->Button(-text =>"Start", -command=>\&start);
my $button_stop = $mframe->Button(-text =>"Stop", -state => "disabled",  -command=>\&stop);
my $button_clear = $mframe->Button(-text =>"Clear",  -command=>\&clear);

my $lframe = $mw->Frame();
my $textfield2 = $lframe->ScrlListbox(-scrollbars=>"se", -height => 6, -width => 62);

$mframe->grid(-row=>1, -column=>1, -rowspan=>10, -columnspan=>4);
$textfield1->grid(-row=>1, -column=>1, -rowspan=>10);
$button_start->grid(-row=>1, -column=>2);
$button_stop->grid(-row=>2, -column=>2);
$button_clear->grid(-row=>3, -column=>2);
$lframe->grid(-row=>11, -column=>1, -rowspan=>2, -columnspan=>2);
$textfield2->grid(-row=>1, -column=>1, -rowspan=>1, -columnspan=>1);

# disable / enable check fuer stop button
$textfield1->bind('<<ListboxSelect>>', sub { 
        if ($textfield1->curselection()) {
                $button_stop->configure( -state => "normal");
        }
        else {
                $button_stop->configure( -state => "disabled");
        }
} );

View full thread Button bei event ausgrauen/disablen