gerardo castro <gerardo.castro.mtz@xxxxxxxxx> wrote:
> I have used perl/tk two or threee times, only because its very hard. I
> need it just for making small interfaces with two textboxes, a combo,
> some buttons a list, etc. And I found it very hard.
>
> So I think it is posible to make an intermediate language to create
> the UI (I know there are IDES like komodo, but they are harder). I
> thougt maybe an html like language could be cool and give speed.
>
> Here is the code I was talking about:
>
> ---*BEGIN*---
> <mainwindow width=400 height=300 title="Miprograma" id=mw>
> <label id="label1" border=2 relief="raise">
> <text value="Escribe aqui tu texto" id=text1 size=100
> onchange="perl:label1->text = 'something like'">
> <button textvariable="perl:$nombreboton" onclick="funcionboton">
> <text id=textolargo1 height=400 width=400 alt="Put here your text">
> This text is contained on it
>
> </text>
> <mainwindow>
>
> <perl>
> put code for the script here
> </perl>
>
> ---*END*---
>
A nearly aquivalent perl/Tk script could look like this:
use Tk;
my $mw = MainWindow->new(-width => 400, -height => 300, -title => "Miprograma");
my $b = $mw->Balloon;
my $label1 = $mw->Label(-border => 2, -relief => "raise")->pack;
my $text1text = "Escribe aqui tu texto";
my $text1 = $mw->Entry(-width => 100, -textvariable => \$text1text,
-validate => "all", -vcmd => sub {
$label1->configure(-text => "something like") })->pack;
my $nombreboton;
$mw->Button(-textvariable => \$nombreboton,
-command => \&functionboton)->pack;
my $texttolargo1 = $mw->Text(-width => 400/10, -height => 400/10)->pack;
$texttolargo1->insert("end", <<EOF);
This text is contained on it
EOF
$b->attach($texttolargo1, -msg => "Put here your text");
MainLoop;
It's slightly longer, because variables are declared, a geometry manager
is explicitely used (there's no pack or grid support in your example),
and your example uses some sugar not found in Perl/Tk like alt="..."
or the on...="..." attributes.
I think that perl programmers are accustomed enough writing perl scripts,
and a html- or xml-like language would be too simple for most but the
simplest problems.
But some of your thoughts there are interesting. You introduced attributes
like -on..., -alt, -value, the inner contents of an <text> tag. Maybe it
would be nice to introduce those options to a yet-to-create higher-level Tk
package --- for those people who want it even easier.
Regards,
Slaven
--
__o Slaven Rezic
_`\<,_ slaven <at> rezic <dot> de
__(_)/ (_)____
______________________________________________________________________________
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@xxxxxxxxxxxxxxxxxx
|