Thread [Tk] Callback ausführen (2 answers)
Opened by Kean at 2014-05-22 13:40

johne
 2019-11-04 04:51
#190840 #190840
User since
2019-11-04
1 Artikel
BenutzerIn
[default_avatar]
2014-05-22T11:40:26 Kean
In diesem Thread: [Tk] Tk-Spinbox - Command ausführen
habe ich erfahren wie man einen Callback Command aus einem Widget auslesen und mit Tk-Bind mit einer Aktion ausführen kann.

Gibt es auch eine Möglichkeit diesen Callback so zu starten/auszuführen?

Ich habe dies mal ausprobiert, es gibt aber keinen Befehlt der Call heißt:
Code: (dl )
1
2
3
4
my $spinbox = $mw->Spinbox(-from => 1980, -to => 2037, -command => sub {
print $anzeige_jahr_w->get()})->pack();

call $spinbox->cget(-command);


Den Befehl gibt es. Er heisst invoke().
$spinbox->invoke();  # fuehrt den -callback aus

Hierzu auf Seite 110 von Mastering Perl/Tk
The invoke method invokes the subroutine to which the -command option points. Once you use -command to assign the callback, whenever you need to perform that same task, you can use invoke.

Die Methode invoke ruft die Unterroutine auf, auf die die Option -command verweist. Wenn Du den Rückruf mit -command zugewiesen hast und dieselbe Aufgabe ausführen musst, kannst Du invoke verwenden.

Etwas spaet - bin erst Ende 2019 zu diesem Forum gekommen - hoffe dies hilft.
Last edited: 2019-11-04 07:59:42 +0100 (CET)

View full thread [Tk] Callback ausführen