Thread: [tcltk-perl] few thoughts about Tcl-Tk
Brought to you by:
hobbs
From: Konovalov, V. <vko...@sp...> - 2004-04-14 06:14:14
|
Dear Jeff, 1. Right now there exist widgets (like Button, Label and so on) that when created live in their own package, say, Tcl::Tk::Widget::Button This will help in not interfering methods between widgets. Works better than I expected. (I thought doing this will be more complicated than it actually became) However complicated widgets behave differently, say, "Menu" becomes Tcl::Tk::Widget and not Tcl::Tk::Widget::Menu. I am going to fix this, probably before releasing to CPAN. Do you have additional ideas on this? 2. It is actually not clear to me why most code in "need_tk" must present there, and therefore much of TODO there. I mean why I code like $int->Eval("destroy [tixTree .___ptk_tree]"); #TODO must be there. Do you have an idea why calling $int->call("tixTree", ...) is not good enough to find proper name? Something with TCL autoloading? (BTW tk_optionMenu behaves same way) 3. Is it good to create some support "tcl" or "tk" files inside Tcl-Tk just to ease processing? Create some Tcl/Tk wrappers to move some logic from Tcl::Tk to nearby files 4. I think it would be very nice in addition to existing perlTk compatibility widgets to create a while bunch of new widgets with same logic, and this will create some more interest of using module. Best regards, Vadim. |
From: Gisle A. <gi...@Ac...> - 2004-04-14 08:57:05
|
The Tcl and Tcl-Tk package both come with a file called 'ceMakefile.pl'. This will get installed on 'make install' as all *.pl are. I suggest you rename it as 'ceMakefile.PL' or just make sure that the standard Makefile.PL can support WinCE. --Gisle |
From: Gisle A. <gi...@Ac...> - 2004-04-14 09:12:45
|
Suggested cleanup patch for Tcl's Makefile.PL. It gets rid of badly handcoded option parsing and replace it with Getopt::Long. Similar patch also makes sense for the Tcl-Tk one. --Gisle Index: Makefile.PL =================================================================== RCS file: /cvsroot/tcltkce/Tcl/Makefile.PL,v retrieving revision 1.3 diff -u -p -u -r1.3 Makefile.PL --- Makefile.PL 9 Apr 2004 19:05:23 -0000 1.3 +++ Makefile.PL 14 Apr 2004 08:52:43 -0000 @@ -1,33 +1,24 @@ +#!/usr/bin/perl -w + # before running this script make sure you have 'tclsh' in your path, # and this 'tcl' distribution is required one. # FreeBSD users may want to modify name of tcl interpreter (this is # $tclsh variable below) as long as 'tclsh' does not work in their case +use strict; +use Getopt::Long qw(GetOptions); + my $tclsh = 'tclsh'; my $tclconfig; my $buildspec; my $libpath; my $incpath; -while (1) { - # Handle any --options - last unless @ARGV[0] =~ /^--/; - my $opt = shift @ARGV; - my $val = shift @ARGV; - if ($opt eq "--tclsh") { - $tclsh = $val; - } - elsif ($opt eq "--tclconfig") { - $tclconfig = $val; - } - elsif ($opt eq "--buildspec") { - $buildspec = 1; - } - else { - die "unknown option '$opt', must be --tclsh, --tclconfig or --buildspec\n"; - } -} - +GetOptions("tclsh=s", \$tclsh, + "tclconfig=s", \$tclconfig, + "buildspec", \$buildspec) + || die "Usage: perl Makefile.PL [--tclsh <path>] [--tclconfig <path>] " . + "[--buildspec] [<makemaker opts>...]\n"; if ($tclconfig) { die "Tcl config file '$tclconfig' not found\n" unless (-f $tclconfig); |
From: Gisle A. <gi...@Ac...> - 2004-04-14 09:21:57
|
Apparently the code works with perl-5.6 and better, and fails with perl-5.005. Is this what is expected? I ask because I was looking into suggesting cleanups for the perl code, but was not sure which perl's you try to stay portabe to. If perl-5.6 is the baseline, then it is a good idea to put a: require 5.006; statement in the Makefile.PL and Tcl.pm to document this. Probably also say so in the README. --Gisle |
From: Gisle A. <gi...@Ac...> - 2004-04-14 09:26:22
|
In Tcl.pm I see this code: unless (defined $Tcl::Tk::VERSION) { package Tcl::Tk; # define empty package } use vars qw(@ISA); @ISA = qw(DynaLoader Tcl::Tk); Why is Tcl as subclass of Tck::Tk insted of the other way around? The other way seems more logical. --Gisle |
From: Gisle A. <gi...@Ac...> - 2004-04-14 09:41:20
|
This patch seems like a good idea to me. --Gisle Index: Tcl.pm =================================================================== RCS file: /cvsroot/tcltkce/Tcl/Tcl.pm,v retrieving revision 1.9 diff -u -p -u -r1.9 Tcl.pm --- Tcl.pm 12 Apr 2004 23:09:56 -0000 1.9 +++ Tcl.pm 14 Apr 2004 09:18:45 -0000 @@ -302,28 +302,6 @@ sub LINK_READ_ONLY () { 0x80 } bootstrap Tcl; -# This is a crude list-creating routine. 'icall' convert perl array -# refs into Tcl list objects efficiently, so this isn't necessary. -# It is also not "comprehensive", so should be used as a last resort. -sub listify { - my $res; - for my $arg (@_) { - my $ref = ref($arg); - $res .= " " if $res; - if (!$ref && $arg =~ / /) { - $res .= "{$arg}"; - } - elsif ($ref eq "ARRAY") { - $res .= "{" . listify(@$arg) . "}"; - } - else { - $arg =~ s/\\/\\\\/g; - $res .= $arg; - } - } - return $res; -} - #TODO make better wording here # %anon_refs keeps track of anonymous subroutines that were created with # "CreateComand" method during process of transformation of arguments for @@ -386,12 +364,6 @@ sub call { # XXX needs testing $args[$argcnt] = $interp->create_tcl_sub(sub {$arg->[0]->(@$arg[1..$#$arg])}); - } - else { - # Do nothing here, as icall recurses into ARRAYs and - # turns them into true Tcl lists - # Should properly turn ARRAY into Tcl list - #$args[$argcnt] = listify(@$arg); } } } |
From: Gisle A. <gi...@Ac...> - 2004-04-14 11:15:13
|
This patch make Tcl::Ev more correct. ==== //depot/users/gisle/hacks/Tcl/Tcl.pm#2 - /home/gisle/hacks/Tcl/Tcl.pm ==== Index: users/gisle/hacks/Tcl/Tcl.pm --- users/gisle/hacks/Tcl/Tcl.pm.~1~ Wed Apr 14 13:12:40 2004 +++ users/gisle/hacks/Tcl/Tcl.pm Wed Apr 14 13:12:40 2004 @@ -434,7 +434,7 @@ } sub Ev { my $s = shift; - if (length($s)>1) { + if (!defined($s) || length($s) != 1) { warn "Event variable must have length 1"; return; } End of Patch. |
From: Gisle A. <gi...@Ac...> - 2004-04-15 13:26:38
|
Gisle Aas <gi...@ca...> writes: > This patch make Tcl::Ev more correct. I've applied this patch myself now; Tcl.pm -r1.14 --Gisle > ==== //depot/users/gisle/hacks/Tcl/Tcl.pm#2 - /home/gisle/hacks/Tcl/Tcl.pm ==== > Index: users/gisle/hacks/Tcl/Tcl.pm > --- users/gisle/hacks/Tcl/Tcl.pm.~1~ Wed Apr 14 13:12:40 2004 > +++ users/gisle/hacks/Tcl/Tcl.pm Wed Apr 14 13:12:40 2004 > @@ -434,7 +434,7 @@ > } > sub Ev { > my $s = shift; > - if (length($s)>1) { > + if (!defined($s) || length($s) != 1) { > warn "Event variable must have length 1"; > return; > } > End of Patch. |