Thread: [tcltk-perl] Package Img
Brought to you by:
hobbs
From: Paul F. <fa...@ca...> - 2004-08-31 13:46:06
|
I am now getting this error can't find package Img at /usr/lib/perl5/site_perl/5.8.3/Tcl/Tk.pm line 704. I am trying to do the following $Photos{"Photo"} = $curfrm->Photo(-palette => 2, -width => $wdth, -height => $hght); Am package am I missing? After this I believe I will be close to having my app run under Tcl::Tk at least under a Linux i386 type machine. The next hurdle will be getting it to run under a wince PDA. |
From: Jeff H. <je...@Ac...> - 2004-08-31 15:22:31
|
Paul Falbe wrote: > I am now getting this error > > can't find package Img at /usr/lib/perl5/site_perl/5.8.3/Tcl/Tk.pm line 704. > > I am trying to do the following > > $Photos{"Photo"} = $curfrm->Photo(-palette => 2, > -width => $wdth, > -height => $hght); The Img package is a Tcl extension. See http://tkimg.sourceforge.net/. I dislike and disagree that this should be required for the Photo method. You will find the need_tk('Img') call there, but that's not really accurate, especially for what you have above, which is creating a blank photo. Img is a Tcl extension that adds numerous graphicals image formats (about a dozen more, including JPEG and PNG). If you can live with the standard GIF and P*M support, you will never need Img. IMO this requirement should be moved to a higher level. -- Jeff Hobbs, The Tcl Guy http://www.ActiveState.com/, a division of Sophos |
From: Paul F. <fa...@ca...> - 2004-08-31 15:32:03
|
On Tue, Aug 31, 2004 at 08:22:23AM -0700, Jeff Hobbs wrote: > Paul Falbe wrote: > > >I am now getting this error > > > >can't find package Img at /usr/lib/perl5/site_perl/5.8.3/Tcl/Tk.pm line > >704. > > > >I am trying to do the following > > > >$Photos{"Photo"} = $curfrm->Photo(-palette => 2, > > -width => $wdth, > > -height => $hght); > > The Img package is a Tcl extension. See http://tkimg.sourceforge.net/. > I dislike and disagree that this should be required for the Photo > method. You will find the need_tk('Img') call there, but that's not > really accurate, especially for what you have above, which is creating > a blank photo. Img is a Tcl extension that adds numerous graphicals > image formats (about a dozen more, including JPEG and PNG). If you can > live with the standard GIF and P*M support, you will never need Img. > IMO this requirement should be moved to a higher level. I could live with GIF but looks like like there is more to it than just commenting out that line. I guess I will install tkimg... |
From: Vadim K. <va...@ar...> - 2004-08-31 19:02:07
|
> The Img package is a Tcl extension. See http://tkimg.sourceforge.net/. > I dislike and disagree that this should be required for the Photo > method. You will find the need_tk('Img') call there, but that's not > really accurate, especially for what you have above, which is creating > a blank photo. Img is a Tcl extension that adds numerous graphicals > image formats (about a dozen more, including JPEG and PNG). If you can > live with the standard GIF and P*M support, you will never need Img. > IMO this requirement should be moved to a higher level. > As far as I remember that "need_tk('Img')" was added by me, and I just didn't knew better way of doing things. I beleive we should require 'Img' only when it is really needed, for example at a moment when JPEG processing is required. I will try adding code for this. Best regards, Vadim. |
From: Jeff H. <je...@Ac...> - 2004-09-02 15:15:44
|
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 |
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 |
From: Jeff H. <je...@Ac...> - 2004-09-03 23:08:07
|
The following is a working translation of the Tcl doodle code. There are others ways to express some of this stuff, but this works: #!/usr/bin/perl use Tcl::Tk qw/:perlTk/; my $mw = MainWindow->new(); my $c = $mw->Canvas(-background => "white") ->pack(-fill => 'both', -expand => 1); our $id; doodle($c); MainLoop; sub doodle { my ($w, $color) = @_; my $color = "black" unless defined $color; Tcl::Tk::bind($w->interp, $w, '<1>', [\&doodle_start, Tcl::Ev('%x', '%y'), $w, $color]); Tcl::Tk::bind($w->interp, $w, '<B1-Motion>', [\&doodle_move, Tcl::Ev('%x', '%y'), $w]); # bind $w <1> [list doodle'start %W %x %y $color] # bind $w <B1-Motion> {doodle'move %W %x %y} } sub doodle_start { my ($x, $y, $w, $color) = @_; $id = $w->create('line', $x, $y, $x, $y, -fill => $color); # set ::_id [$w create line $x $y $x $y -fill $color] } sub doodle_move { my ($x, $y, $w) = @_; my @coords = $w->coords($id); unshift @coords, $x, $y; $w->coords($id, @coords); # $w coords $::_id [concat [$w coords $::_id] $x $y] } Jeff Hobbs, The Tcl Guy http://www.ActiveState.com/, a division of Sophos > -----Original Message----- > From: Paul Falbe [mailto:fa...@ca...] > Sent: Thursday, September 02, 2004 8:52 AM > To: Jeff Hobbs > Cc: tcl...@li... > Subject: Re: [tcltk-perl] Package Img > > > > 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 > |
From: Paul F. <fa...@ca...> - 2004-09-07 13:09:53
|
Works great. How could I dump results to a file in GIF/PNG format. And clear pad and load an image. Also, I am going to go back again and try and get my MIPS based CASIO working again. You said I should make sure I have a proper TCL/TK directory structure. Is there any way you could do a File listing of your /Storage Card/ Tcl/Tk directory so I can compare. Also, any chance of a output of something like for $key ( keys %ENV ) { print "$key $ENV{$key}\n"; } I would think between those 2 things should be able to fix not being able to fix bwidget access. On Fri, Sep 03, 2004 at 04:07:52PM -0700, Jeff Hobbs wrote: > The following is a working translation of the Tcl doodle code. > There are others ways to express some of this stuff, but this > works: > > #!/usr/bin/perl > > use Tcl::Tk qw/:perlTk/; > my $mw = MainWindow->new(); > my $c = $mw->Canvas(-background => "white") > ->pack(-fill => 'both', -expand => 1); > > our $id; > doodle($c); > > MainLoop; > > sub doodle { > my ($w, $color) = @_; > my $color = "black" unless defined $color; > Tcl::Tk::bind($w->interp, $w, '<1>', > [\&doodle_start, Tcl::Ev('%x', '%y'), $w, $color]); > Tcl::Tk::bind($w->interp, $w, '<B1-Motion>', > [\&doodle_move, Tcl::Ev('%x', '%y'), $w]); > # bind $w <1> [list doodle'start %W %x %y $color] > # bind $w <B1-Motion> {doodle'move %W %x %y} > } > > sub doodle_start { > my ($x, $y, $w, $color) = @_; > $id = $w->create('line', $x, $y, $x, $y, -fill => $color); > # set ::_id [$w create line $x $y $x $y -fill $color] > } > > sub doodle_move { > my ($x, $y, $w) = @_; > my @coords = $w->coords($id); > unshift @coords, $x, $y; > $w->coords($id, @coords); > # $w coords $::_id [concat [$w coords $::_id] $x $y] > } > > Jeff Hobbs, The Tcl Guy > http://www.ActiveState.com/, a division of Sophos > > > -----Original Message----- > > From: Paul Falbe [mailto:fa...@ca...] > > Sent: Thursday, September 02, 2004 8:52 AM > > To: Jeff Hobbs > > Cc: tcl...@li... > > Subject: Re: [tcltk-perl] Package Img > > > > > > > > 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 > > |
From: Paul F. <fa...@ca...> - 2004-09-07 14:00:23
|
Jeff, Nevermind on the file list on your Tcl/Tk installation. Found it was my bad. I didn't put the "lower" subroutine into the Tk.pm for my MIPS device. One strange thing on your doodle.pl It works great on my i386 Linux box which has tcl/tk 8.4.7 but on my CASIO which has 8.4.4 all lines start from the upper left-hand corner. Any ideas?? I still need to know how to save my doodle to a GIF/PNG. And it seems I can do things like this my @loadfiles = <\\Storage Card\\myapp\\files\\*.txt>; How do you get a list of files with perl58m on wince devices? Thanks! -Paul On Fri, Sep 03, 2004 at 04:07:52PM -0700, Jeff Hobbs wrote: > The following is a working translation of the Tcl doodle code. > There are others ways to express some of this stuff, but this > works: > > #!/usr/bin/perl > > use Tcl::Tk qw/:perlTk/; > my $mw = MainWindow->new(); > my $c = $mw->Canvas(-background => "white") > ->pack(-fill => 'both', -expand => 1); > > our $id; > doodle($c); > > MainLoop; > > sub doodle { > my ($w, $color) = @_; > my $color = "black" unless defined $color; > Tcl::Tk::bind($w->interp, $w, '<1>', > [\&doodle_start, Tcl::Ev('%x', '%y'), $w, $color]); > Tcl::Tk::bind($w->interp, $w, '<B1-Motion>', > [\&doodle_move, Tcl::Ev('%x', '%y'), $w]); > # bind $w <1> [list doodle'start %W %x %y $color] > # bind $w <B1-Motion> {doodle'move %W %x %y} > } > > sub doodle_start { > my ($x, $y, $w, $color) = @_; > $id = $w->create('line', $x, $y, $x, $y, -fill => $color); > # set ::_id [$w create line $x $y $x $y -fill $color] > } > > sub doodle_move { > my ($x, $y, $w) = @_; > my @coords = $w->coords($id); > unshift @coords, $x, $y; > $w->coords($id, @coords); > # $w coords $::_id [concat [$w coords $::_id] $x $y] > } > > Jeff Hobbs, The Tcl Guy > http://www.ActiveState.com/, a division of Sophos > > > -----Original Message----- > > From: Paul Falbe [mailto:fa...@ca...] > > Sent: Thursday, September 02, 2004 8:52 AM > > To: Jeff Hobbs > > Cc: tcl...@li... > > Subject: Re: [tcltk-perl] Package Img > > > > > > > > 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 > > |
From: Paul F. <fa...@ca...> - 2004-09-07 20:24:59
|
Ok, I've solved all my issues save one. It seems that to save a Canvas need the Photo method. That is part of tkimg. Is there somewhere I can get binaries of tkimg for Wince for both ARM and Mips processors? On Fri, Sep 03, 2004 at 04:07:52PM -0700, Jeff Hobbs wrote: > The following is a working translation of the Tcl doodle code. > There are others ways to express some of this stuff, but this > works: > > #!/usr/bin/perl > > use Tcl::Tk qw/:perlTk/; > my $mw = MainWindow->new(); > my $c = $mw->Canvas(-background => "white") > ->pack(-fill => 'both', -expand => 1); > > our $id; > doodle($c); > > MainLoop; > > sub doodle { > my ($w, $color) = @_; > my $color = "black" unless defined $color; > Tcl::Tk::bind($w->interp, $w, '<1>', > [\&doodle_start, Tcl::Ev('%x', '%y'), $w, $color]); > Tcl::Tk::bind($w->interp, $w, '<B1-Motion>', > [\&doodle_move, Tcl::Ev('%x', '%y'), $w]); > # bind $w <1> [list doodle'start %W %x %y $color] > # bind $w <B1-Motion> {doodle'move %W %x %y} > } > > sub doodle_start { > my ($x, $y, $w, $color) = @_; > $id = $w->create('line', $x, $y, $x, $y, -fill => $color); > # set ::_id [$w create line $x $y $x $y -fill $color] > } > > sub doodle_move { > my ($x, $y, $w) = @_; > my @coords = $w->coords($id); > unshift @coords, $x, $y; > $w->coords($id, @coords); > # $w coords $::_id [concat [$w coords $::_id] $x $y] > } > > Jeff Hobbs, The Tcl Guy > http://www.ActiveState.com/, a division of Sophos > > > -----Original Message----- > > From: Paul Falbe [mailto:fa...@ca...] > > Sent: Thursday, September 02, 2004 8:52 AM > > To: Jeff Hobbs > > Cc: tcl...@li... > > Subject: Re: [tcltk-perl] Package Img > > > > > > > > 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 > > |
From: Jeff H. <je...@Ac...> - 2004-09-07 20:30:45
|
> Ok, I've solved all my issues save one. It seems that > to save a Canvas need the Photo method. That is part of > tkimg. Is there somewhere I can get binaries of tkimg for > Wince for both ARM and Mips processors? You really don't need the tkimg module, unless you want some other format than GIF or PPM. I don't know of any ports to WinCE for Img, and it wouldn't be an easy port. It relies on the graphics libraries for the other formats, like libtiff, libpng, libjpeg, so you would have to have those ported first (which they are, in some cases). Jeff Hobbs, The Tcl Guy http://www.ActiveState.com/, a division of Sophos |
From: Paul F. <fa...@ca...> - 2004-09-07 20:34:25
|
On Tue, Sep 07, 2004 at 01:27:52PM -0700, Jeff Hobbs wrote: > > Ok, I've solved all my issues save one. It seems that > > to save a Canvas need the Photo method. That is part of > > tkimg. Is there somewhere I can get binaries of tkimg for > > Wince for both ARM and Mips processors? > > You really don't need the tkimg module, unless you want > some other format than GIF or PPM. I don't know of any > ports to WinCE for Img, and it wouldn't be an easy port. > It relies on the graphics libraries for the other formats, > like libtiff, libpng, libjpeg, so you would have to have > those ported first (which they are, in some cases). What would I need to comment out so it stops complaining about the need of "Img"? |