Thread Bei Tk in den Mainloop eingreifen?? (8 answers)
Opened by DocJunioR at 2005-09-16 10:42

renee
 2005-09-16 12:05
#44571 #44571
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
So ähnlich könnte man es machen:
Skript:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/perl

use strict;
use warnings;
use Tk;
use lib qw(.);
use ActionListener;

my $mw = MainWindow->new();
my $label = $mw->Label(-text => 'test')->pack();
my $actionlistener = ActionListener->new();

$actionlistener->add($label);

MainLoop;


ActionListener.pm:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package ActionListener;

use Tk;

sub new{
my $self = {};
bless $self,shift;
return $self;
}

sub add{
my ($self,$widget) = @_;
$widget->Tk::bind($widget,'<Button-1>',[\&left]);
}

sub left{
print "linke Maustaste gedrückt...\n";
}

1;
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Bei Tk in den Mainloop eingreifen??