Schrift
[thread]4679[/thread]

Button aktivieren und deaktivieren

Leser: 1


<< >> 2 Einträge, 1 Seite
Arasiel
 2003-11-24 09:43
#45738 #45738
User since
2003-11-12
39 Artikel
BenutzerIn
[default_avatar]
Hallo,

ich habe folgendes Problem:
Ich habe bei meinem Programm eine TK-Oberfläche mit einer Listbox und einem Button.
Der Button ist zu Beginn deaktiviert (siehe Code unten) und soll erst aktiviert werden,
wenn in der Listbox ein Element angeklickt wird. Dieses Element wird dann in der LB gelöscht und der Button soll wieder deaktiviert werden.

Wie kann ich den Button aktivieren und wieder deaktivieren?

Code: (dl )
1
2
3
4
5
6
my $delete_button_left = $frame_top_left->Button(-text => 'Delete selected Item', 
-width=> 15,
    -activebackground => "red",
    -state => "disabled",  #solange nix in der linken Listbox markiert ist, kann ich nicht auf diesen Button drücken
    -command => \&delete_table_top_left )
    ->pack();
   
Code: (dl )
1
2
3
4
5
6
sub delete_table_top_left
{
$select_top_left = $listbox_top_left->curselection;
$select_top_left = $listbox_top_left->get($select_top_left);
$listbox_top_left->delete($listbox_top_left->curselection);
}


Vielen Dank im Voraus für die Hilfe!

Gruß,

Markus
Crian
 2003-11-24 11:52
#45739 #45739
User since
2003-08-04
5866 Artikel
ModeratorIn
[Homepage]
user image
Code: (dl )
$delete_button_left->configure(-state => 'normal');


bzw.

Code: (dl )
$delete_button_left->configure(-state => 'disabled');



Edit: bzw. 'active', siehe Tk::Button :

Quote
Name: state
Class: State
Switch: -state
Specifies one of three states for the button: normal, active, or
disabled. In normal state the button is displayed using the
foreground and background options. The active state is typically
used when the pointer is over the button. In active state the button
is displayed using the activeForeground and activeBackground
options. Disabled state means that the button should be insensitive:
the default bindings will refuse to activate the widget and will
ignore mouse button presses. In this state the disabledForeground
and background options determine how the button is displayed.
\n\n

<!--EDIT|Crian|1069667703-->
s--Pevna-;s.([a-z]).chr((ord($1)-84)%26+97).gee; s^([A-Z])^chr((ord($1)-52)%26+65)^gee;print;

use strict; use warnings; Link zu meiner Perlseite
<< >> 2 Einträge, 1 Seite



View all threads created 2003-11-24 09:43.