Leser: 1
|< 1 2 >| | 11 Einträge, 2 Seiten |
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
#!/usr/bin/perl -w
use strict;
use Tk;
&hauptfenster();
sub hauptfenster
{
my $hauptfenster=new MainWindow(-title=>"Manuelles fahren", -width=>"640", -height=>"480");
my $text1=$hauptfenster->Label(-text=>"Drücken Sie auf die Tasten um die Mschine zu bewegen", -relief=>"groove");
$text1->place(-x=>"20", -y=>"20", -width=>"600", -height=>"50");
my $button1=$hauptfenster->Button(-text=>"hoch", -command=>sub{&fahr("oben")});
$button1->place(-x=>"270", -y=>"100", -width=>"100", -height=>"100");
my $button2=$hauptfenster->Button(-text=>"links", -command=>sub{&fahr("links")});
$button2->place(-x=>"170", -y=>"200", -width=>"100", -height=>"100");
my $button3=$hauptfenster->Button(-text=>"rechts", -command=>sub{&fahr("rechts")});
$button3->place(-x=>"370", -y=>"200", -width=>"100", -height=>"100");
my $button4=$hauptfenster->Button(-text=>"runter", -command=>sub{&fahr("unten")});
$button4->place(-x=>"270", -y=>"300", -width=>"100", -height=>"100");
MainLoop;
}
$button1->bind('<ButtonRelease-1>',sub{print "Button 1 losgelassen"});
$button1->bind('<ButtonPress-1>',sub{print "Button 1 gedrueckt"});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use Tk;
my $mw = new MainWindow;
my $b = $mw->Button(-text => 'Run')->pack(-fill => 'x');
my $id;
my $i;
$b->bind('<ButtonPress-1>' => sub { $i = 0;
$id = $mw->repeat(2, sub {print ++$i, "\n"}) } );
$b->bind('<ButtonRelease-1>' => sub { $id->cancel() } );
MainLoop();
|< 1 2 >| | 11 Einträge, 2 Seiten |