Re: [tcltk-perl] Package Img
Brought to you by:
hobbs
From: Paul F. <fa...@ca...> - 2004-09-02 15:52:43
|
here is my simplistic attach at bind to canvas. I Can't get it to for for "<1>". #!/usr/bin/perl use Tcl::Tk qw/:perlTk/; my $MW = MainWindow->new(); my $C = $MW->Canvas(-height => '100', -width => '100' )->pack(-fill => 'both'); my $f = $C->Frame->pack; my $c =$f->Canvas(-width => '100', -height => '100', -highlightthickness => 0, -background => "#ffffff")->pack; $c->bind('canvas', '<1>', \&foo); MainLoop; sub foo { print "foo\n"; } On Thu, Sep 02, 2004 at 08:20:14AM -0700, Jeff Hobbs wrote: > Paul Falbe wrote: > > >Would you happen to have a example of a scribble program using perl Tcl/TK? > > Not in Perl Tcl::Tk, but this is so simple the translation should > be easy: > > From http://wiki.tcl.tk/9625 > > proc doodle {w {color black}} { > bind $w <1> [list doodle'start %W %x %y $color] > bind $w <B1-Motion> {doodle'move %W %x %y} > } > proc doodle'start {w x y color} { > set ::_id [$w create line $x $y $x $y -fill $color] > } > proc doodle'move {w x y} { > $w coords $::_id [concat [$w coords $::_id] $x $y] > } > pack [canvas .c -bg white] -fill both -expand 1 > doodle .c > bind .c <Double-3> {%W delete all} > > Anyone undertaking the exercise should post it back here for > others to see the translation. > > -- > Jeff Hobbs, The Tcl Guy > http://www.ActiveState.com/, a division of Sophos |