Bonjour,

Mon but principal étant de dessiner, j'essaye de lancer un canvas, mais après quelques modifications, je bloque quand même.
Le script en perl 5 (introduction à Perl/Tk)

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
 
$c = $mw->Scrolled("Canvas")->pack();
$canevas = $c->Subwidget("canvas");
$canevas->Tk::bind("<Button-1>", [ \&affiche_xy, Ev('x'), Ev('y') ]);
sub affiche_xy {
my ($canev, $x, $y) = @_;
print "(x,y) = ", $canev->canvasx($x), ", ",
$canev->canvasy($y), "\n";
}
Le mien

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
#!/opt/rakudo-star/install/bin/perl6
 
use Inline::Perl5;
use Tk:from<Perl5>;
 
sub getXY($canev,$x,$y) {
    say $canev.canvasx($x), $canev.canvasy($y);
}
 
my $window=MainWindow.new();
$window.title('KanDeLa');
 
my $drawing=$window.Scrolled('Canvas','-width',400,'-height',300,'background','white').pack();
 
my $plan=$drawing.Subwidget("canvas");
$plan.createOval(0,0,150,150);
$plan.CanvasBind("<Button-3>", {say('ok')});
$plan.CanvasBind("<Button-1>",  <getXY  Ev('x') Ev('y')>);
 
MainLoop;
Le click avec le bouton droit (3) fonctionne, mais pas avec celui avec le bouton gauche (1)
J'ai comme message d'erreur

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 
Tk::Error: Failed to AUTOLOAD 'Tk::Canvas::getXY' at -e line 0.
 Carp::croak at /usr/share/perl/5.24/Carp.pm line 167
 Tk::Widget::__ANON__ at /usr/lib/x86_64-linux-gnu/perl5/5.24/Tk/Widget.pm line 347
 <Button-1>
 (command bound to event)
Une idée ?

PS : J'ai aussi des Warning, je pense non-bloquant pour ce que je veux faire, est-ce corrigeable ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
Use of inherited AUTOLOAD for non-method Tk::Frame::AddScrollbars() is deprecated at /usr/lib/x86_64-linux-gnu/perl5/5.24/Tk/Widget.pm line 1284.
Use of inherited AUTOLOAD for non-method Tk::Frame::freeze_on_map() is deprecated at blib/lib/Tk/Frame.pm (autosplit into blib/lib/auto/Tk/Frame/AddScrollbars.al) line 233.
Use of inherited AUTOLOAD for non-method Tk::Frame::queuePack() is deprecated at blib/lib/Tk/Frame.pm (autosplit into blib/lib/auto/Tk/Frame/scrollbars.al) line 357.