For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > February 2006 > Tk::Canvas (i) how to get an id? (ii) vertical text?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Tk::Canvas (i) how to get an id? (ii) vertical text?
january.weiner@gmail.com

2006-02-09, 7:01 pm

Hello all,

I have two problems with perl Tk.

First question to you: given a Canvas tag, how to find the id's of the
elements that match a tag? That is, something like
$canvas->gettags('current'), but returning the id's of the elements, and
not their tags.

Second question: is it possible, with default Tk::Canvas, to get vertical text?
I don't mean a workaround like createText(($x, $y), -text=>$blah, -width=>1),
but text that is rotated by 90 degree.

Thanks in advance!

January

--
------------ January Weiner 3 ---------------------+---------------
Division of Bioinformatics, University of Muenster | Schloßplatz 4
(+49)(251)8321634 | D48149 Münster
http://www.uni-muenster.de/Biologie.Botanik/ebb/ | Germany
thundergnat

2006-02-09, 7:01 pm

january.weiner@gmail.com wrote:
> Hello all,
>
> I have two problems with perl Tk.
>
> First question to you: given a Canvas tag, how to find the id's of the
> elements that match a tag? That is, something like
> $canvas->gettags('current'), but returning the id's of the elements, and
> not their tags.


I don't know of any simple way to do that... not that there *isn't* one
necessarily. I would think it would be much easier to track the object
ids at the time of creation.


#!/user/bin/perl
use strict;
use warnings;
use Tk;

my @objects;
my @colors = qw(red green blue orange yellow purple tan black white pink);

my $mw = MainWindow->new;

my $can = $mw->Canvas(
-height => 400,
-width => 450,
)->pack(
-fill => 'both',
-expand => 'y'
);

my $label = $mw->Label->pack;

$mw->update;

for ( 0 .. 20 ) {
my $x = rand( $can->width - 25 );
my $y = rand( $can->height - 25 );
my $color = $colors[ rand @colors ];
push @objects,
$can->createOval( $x, $y, ( $x + 25 ), ( $y + 25 ), -fill => $color );
}

add_bindings($_) for @objects;

MainLoop;

sub add_bindings {
my $object = shift;
$can->bind( $object,
'<Enter>' => sub {
$label->configure( -text => "Item id: $object" );
}
);
$can->bind( $object,
'<Leave>' => sub {
$label->configure( -text => '' );
}
);
}


>
> Second question: is it possible, with default Tk::Canvas, to get vertical text?
> I don't mean a workaround like createText(($x, $y), -text=>$blah, -width=>1),
> but text that is rotated by 90 degree.
>


Tk::Canvas can not do that as far as I know. If you need that, you
may be better of looking at Tk::Zinc instead.
http://www.tkzinc.org/
Ch Lamprecht

2006-02-09, 7:01 pm

january.weiner@gmail.com schrieb:
> Hello all,
>
> I have two problems with perl Tk.
>
> First question to you: given a Canvas tag, how to find the id's of the
> elements that match a tag? That is, something like
> $canvas->gettags('current'), but returning the id's of the elements, and
> not their tags.
>

Hello,

use strict;
use warnings;
use Tk;

my $mw = tkinit;
my $canvas = $mw->Canvas()->pack;
for (1..15){
my $id = $canvas->createText(20,$_*15,
-text=>"text $_");
$canvas->addtag('my_tag', 'withtag',$id);
}
my $but= $mw->Button(-text=>'get ids',
-command=>sub{
print join("\n",$canvas->find(withtag=>'my_tag'));
})->pack;
MainLoop();


HTH
Christoph

> Second question: is it possible, with default Tk::Canvas, to get vertical text?
> I don't mean a workaround like createText(($x, $y), -text=>$blah, -width=>1),
> but text that is rotated by 90 degree.
>


If you find a solution for this, please let me know ;)
Zinc does not imlement the postscript method...




--

perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"
Dean Arnold

2006-02-09, 7:01 pm

Ch Lamprecht wrote:
>
>
> If you find a solution for this, please let me know ;)
> Zinc does not imlement the postscript method...
>


IIRC, Slaven had a Tk::RotateText module that worked on
*some* platforms, but I can't seem to find it anywhere
at the moment.

One alternative I've been playing with is to use GD/GD::Text
to create an image of the text, rotate as needed, and then
embed into the canvas. Its a long way round, but should be platform
independent.

Dean Arnold
Presicient Corp.
Tom

2006-02-09, 7:01 pm

This does not rotate characters but does do "vertical" text.

Tom


#!/usr/bin/perl

use Tk;
use strict;

my $mw = MainWindow->new;

my $c = $mw->Canvas
(
-height => 600,
-width => 800,
background => 'snow1',
)->grid;

createTextV($c, 50, 50, -text=>"This is a test.", -tags=>"ccc");
createTextV($c, 70, 50, -text=>"What do you think?", -font =>"Times
22");
createTextV($c, 90, 50, -text=>"What about red?", -fill=>"red",-font
=>"Times 22");

MainLoop;

# end main


sub createTextV { # canvas widget, x,y, then all the text arguments
plus -step=>number
# Writes text from top to bottom.
# For now argument -anchor is removed
# There are three huristic values put in here to get text to look
kind of resonable
# step is the fraction of the letter box height that the next
letter is lowered. Default is 0.80
# upLittle is the fraction of the letter box height that the next
letter is moved up if the previous letter is "small"
# upLittle is also used to move down for decending letters, such as
y,g,...
# upBig is the fraction of the letter box height that the next
letter is moved up when the letter is very small, blank, comma and dot
right now.
use strict;
my $canvas = shift;
my($x,$y) = (shift,shift);
my %args = @_;
my $text = delete($args{-text});
my $anchor = delete($args{-anchor});
my $step = delete($args{-step});
my $tag = delete($args{-tags});
my @letters = split(//,$text);
$tag = "local" . rand() if($tag eq undef); # ugh
# print "args", %args, "\n";;
# OK we know that we have some short and some long letters
# a,c,e,g,m,m,o,p,r,s,t,u,v,w,x,y,z are all short. They could be
moved up a tad
# also g,j,q, and y hang down, the next letter has to be lower
my $th = 0;
my $lc = 0;
# sorry to say, the height of all the letters as returned by bbox is
the same for a given font.
# same is true for the text widget. Nov 2005!
my $letter = shift(@letters);
$canvas->createText($x,$y+$th, -text=>$letter,'-tags'=>$tag, %args,
-anchor=> 'c'); # first letter
my($l, $t, $r, $b) = $canvas->bbox($tag);
my $h = $b - $t;
my $w = $r - $l;
$step = 0.80 if($step eq undef);
$step = 0.80;
my $upLittle = 0.10;
my $upBig = 0.40;
$th = $step*$h + $th;
print "step <$step> h <$h> th <$th> \n";
foreach my $letter (@letters) {
# print "createTestV letter <$letter>\n";
# If the letter is short, move it up a bit.
$th = $th - $upLittle*$h if($letter =~ /[acegmnoprstuvwxyz;:]/); #
move up a little
$th = $th - $upBig*$h if($letter =~ /[ ., ]/); #
move up a lot
# now write the letter
$canvas->createText($x,$y+$th, -text=>$letter, '-tags'=>$tag,
%args, -anchor=> 'c');
# space for the next letter
$th = $step*$h + $th;
$th = $th + $upLittle*$h if($letter =~ /[gjpqy]/); # move down a
bit if the letter hangs down
print "step <$step> h <$h> th <$th> \n";
$lc++;

}
}

Ala Qumsieh

2006-02-09, 9:56 pm

january.weiner@gmail.com wrote:
> Hello all,
>
> I have two problems with perl Tk.
>
> First question to you: given a Canvas tag, how to find the id's of the
> elements that match a tag? That is, something like
> $canvas->gettags('current'), but returning the id's of the elements, and
> not their tags.


I think you're looking for this:

my @ids = $canvas->find(withtag => 'current');

> Second question: is it possible, with default Tk::Canvas, to get vertical text?
> I don't mean a workaround like createText(($x, $y), -text=>$blah, -width=>1),
> but text that is rotated by 90 degree.


Not possible. The only way that I know of is to dynamically create an
image of the rotated text, and show it on the canvas.

--Ala

blah@gmail.com

2006-02-10, 3:57 am

Ala Qumsieh <notvalid@email.com> wrote:
> I think you're looking for this:


> my @ids = $canvas->find(withtag => 'current');


Nope. This does not return the ids, but the tags only. (it _should_,
however, return the tag as well, as this would be consistent with the
"tagOrId" thinking).

j.

--
------------ January Weiner 3 ---------------------+---------------
Division of Bioinformatics, University of Muenster | Schloßplatz 4
(+49)(251)8321634 | D48149 Münster
http://www.uni-muenster.de/Biologie.Botanik/ebb/ | Germany
blah@gmail.com

2006-02-10, 3:57 am

thundergnat <thundergnat@hotmail.com> wrote:
> necessarily. I would think it would be much easier to track the object
> ids at the time of creation.


Tracking isn't enough. When an object get clicked, I need to know
precisely which object has been clicked ('current' is not enough, because I
have some other items associated with that object which the clicking should
influence as well). That is, I need a unique tag for each object. I can
do:

my $id = $canvas->createText(($x, $y), -text=>"blah") ;
$canvas->addtag($id, 'id$id') ;

....which would do the job, but ugly, because it is re-inventing the wheel.
Unique tags are already there!

> Tk::Canvas can not do that as far as I know. If you need that, you
> may be better of looking at Tk::Zinc instead.
> http://www.tkzinc.org/


Zinc does not implement the Postscript method, which is what finally
convinced me to use Tk at all :-))) Not having postscript means that I have
to re-implement all drawing in Postscript :-/ I'd rather hack Tk::Canvas to
get what I need :-)))

Cheers,
January

--
--
------------ January Weiner 3 ---------------------+---------------
Division of Bioinformatics, University of Muenster | Schloßplatz 4
(+49)(251)8321634 | D48149 Münster
http://www.uni-muenster.de/Biologie.Botanik/ebb/ | Germany
blah@gmail.com

2006-02-10, 3:57 am

Ch Lamprecht <christoph.lamprecht.no.spam@web.de> wrote:

> $canvas->addtag('my_tag', 'withtag',$id);


Thanks! That is how I do it now, but I thought that it is lame as we are
creating a tag that is in essence equivalent to the id :-)

> If you find a solution for this, please let me know ;)


OK.

> Zinc does not imlement the postscript method...


Yep :-(

j.

--
------------ January Weiner 3 ---------------------+---------------
Division of Bioinformatics, University of Muenster | Schloßplatz 4
(+49)(251)8321634 | D48149 Münster
http://www.uni-muenster.de/Biologie.Botanik/ebb/ | Germany
january.weiner@gmail.com

2006-02-10, 3:57 am

thundergnat <thundergnat@hotmail.com> wrote:
> necessarily. I would think it would be much easier to track the object
> ids at the time of creation.


Tracking isn't enough. When an object get clicked, I need to know
precisely which object has been clicked ('current' is not enough, because I
have some other items associated with that object which the clicking should
influence as well). That is, I need a unique tag for each object. I can
do:

my $id = $canvas->createText(($x, $y), -text=>"blah") ;
$canvas->addtag('id$id', 'withtag', $id) ;

....which would do the job, but ugly, because it is re-inventing the wheel.
Unique tags are already there!

> Tk::Canvas can not do that as far as I know. If you need that, you
> may be better of looking at Tk::Zinc instead.
> http://www.tkzinc.org/


Zinc does not implement the Postscript method, which is what finally
convinced me to use Tk at all :-))) Not having postscript means that I have
to re-implement all drawing in Postscript :-/ I'd rather hack Tk::Canvas to
get what I need :-)))

Cheers,
January

--
--
------------ January Weiner 3 ---------------------+---------------
Division of Bioinformatics, University of Muenster | Schloßplatz 4
(+49)(251)8321634 | D48149 Münster
http://www.uni-muenster.de/Biologie.Botanik/ebb/ | Germany
zentara

2006-02-10, 7:57 am

On Thu, 9 Feb 2006 18:19:41 +0100 (CET), january.weiner@gmail.com wrote:

>Hello all,
>I have two problems with perl Tk.


Well then, I have to throw my 2 cents in :-)

>
>First question to you: given a Canvas tag, how to find the id's of the
>elements that match a tag? That is, something like
>$canvas->gettags('current'), but returning the id's of the elements, and
>not their tags.


my $id = $canv->find(qw/withtag current/);
my (@ids) = $canv->find(qw/withtag foobar/);


#!/usr/bin/perl
use warnings;
use strict;
use Tk;

my $mw = MainWindow->new();

# first create a canvas widget
my $canvas = $mw->Canvas(width => 300, height => 200)->pack();


my $one = $canvas->createOval(5, 20, 40, 90,
-fill => 'blue',
-outline=>'blue',
-tags => ['blue'],
-stipple => 'gray75',
);

my $two = $canvas->createOval(105, 20, 250, 190,
-fill => 'red',
-outline=>'red',
-tags => ['red'],
-stipple => 'gray12',
);


my $ebutton = $mw->Button(-text => 'Exit',
-command => 'Tk::exit')->pack();


$canvas->Tk::bind("<Motion>", [ \&print_xy, Ev('x'), Ev('y') ]);

MainLoop();

sub print_xy {
my ($canv, $x, $y) = @_;

my (@current) = $canvas->find(qw/withtag current/);
print "id->@current\n";

foreach my $id(@current){
print "tags-> ", $canvas->gettags($id),' ';
}
print "\n";

}
__END__

>
>Second question: is it possible, with default Tk::Canvas, to get vertical text?
>I don't mean a workaround like createText(($x, $y), -text=>$blah, -width=>1),
>but text that is rotated by 90 degree.


Zinc does this easily, and if you are using linux, you don't need
Postscript output to get a screenshot. Use Tk::WinPhoto.

The postscript output of a Tk::Canvas is some sort of bitmap anyways,
a jpg would be just as good.


And although it is heresy to say it here, you might want to
look at Gtk2, which uses Pango and Cairo, and can do rotated text.

Here is a Zinc rotate text. It rotates in a couple of variations. You
also could use GD to make images of placed letters, then put those
images on the canvas.


#!/usr/bin/perl
use warnings;
use strict;
use Tk;
use Tk::Zinc;

my $mw = MainWindow->new();

my $zinc = $mw->Zinc(
#-render => 1,
-width => 400,
-height => 400,
)->pack;

$zinc->fontCreate(
"fonta",
-family => 'arial',
-size => -30,
-weight => 'normal'
);

my $t1 = $zinc->add(
'text', 1,
-position => [ 50, 100 ],
-text => 'foobar',
-font => 'fonta'
);

$zinc->rotate( $t1, -90 , 'degree' );

########################################
########

#or get more complicated with groups

#create a group with it's origin at center
my $origingroup= $zinc->add('group',1,-visible=> 1);
$zinc->scale($origingroup,1,-1); #reverse direction of y axis
$zinc->translate($origingroup,150,150);

my $t2 = $zinc->add(
'text', $origingroup ,
-position => [ 0, 0 ],
-text => 'x',
-font => 'fonta'
);

my $t3 = $zinc->add(
'text', $origingroup,
-position => [ 30, 0 ],
-text => 'y',
-font => 'fonta'
);

my $t4 = $zinc->add(
'text', $origingroup,
-position => [ 60, 0 ],
-text => 'z',
-font => 'fonta'
);

########################################
###########
#clone and rotate
my $group2 = $zinc->clone($origingroup);
$zinc->translate($group2,0,70);

$zinc->rotate($group2, 90, 'degree',150,150);

MainLoop;
__END__



--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
Ch Lamprecht

2006-02-10, 6:58 pm

blah@gmail.com wrote:
> Ch Lamprecht <christoph.lamprecht.no.spam@web.de> wrote:
>
>
>
>
> Thanks! That is how I do it now, but I thought that it is lame as we are
> creating a tag that is in essence equivalent to the id :-)


No, it's not at all equivalent to the id:
One or more tag(s) can be associated to one or more item(s) with the
addtag method whereas the ids are unique.

use strict;
use warnings;
use Tk;

my $mw = tkinit;
$mw->Label(-text=>'click on an item to print its id')->pack;
my $canvas = $mw->Canvas()->pack;
for (1..15){
my @tags = (($_<5?'my_tag':'my_tag2'),($_%2?'my_tag3':'my_tag4'));
my $id = $canvas->createText(20,$_*15, -anchor=>'w',
-text=>"item $_ associated with tags @tags");
for (@tags){$canvas->addtag($_, 'withtag',$id)};
}
for ('my_tag','my_tag2','my_tag3','my_tag4')
{
my $tag = $_;
$mw->Button(-text=>"get ids for $tag",
-command=>sub{
print join("\n",$canvas->find(withtag=>$tag),"\n");
flash($tag);
})->pack;
}

$canvas->bind ('all','<1>',sub{
print "\ncurrent item:\n";
my $id =$canvas->find(withtag=>'current');
print join("\n$id\n");
flash($id);
});
MainLoop();

sub flash{
my $tag = shift;
$canvas->itemconfigure($tag,-fill=>'red');
$mw->after(1000,
sub{$canvas->itemconfigure($tag,-fill=>'black')});
}

__END__

HTH, Christoph


--

perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"
Ch Lamprecht

2006-02-10, 6:58 pm

zentara wrote:
> On Thu, 9 Feb 2006 18:19:41 +0100 (CET), january.weiner@gmail.com wrote:
>



> Zinc does this easily, and if you are using linux, you don't need
> Postscript output to get a screenshot. Use Tk::WinPhoto.
>
> The postscript output of a Tk::Canvas is some sort of bitmap anyways,
> a jpg would be just as good.
>


Hi,
that's not true except, maybe for bitmap- or image-items...
Take a look at a postscript file generated by canvas->postscript in
ghostview or whatever viewer you have available.
Scale it to 800% ...

If you need printed documents of high quality, screenshots are no way!

Christoph

>
>
>



--

perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"
January Weiner

2006-02-10, 6:58 pm

Ch Lamprecht <christoph.lamprecht.no.spam@web.de> wrote:
[color=darkred]
> No, it's not at all equivalent to the id:
> One or more tag(s) can be associated to one or more item(s) with the
> addtag method whereas the ids are unique.


Yeah, I know, what I meant was: I add the tag equal to the id to eventually
get the real, unique id when I need it:

my $id = $canvas->createText($x, $y, -text=>"blah", -tags=>['one', 'text', 'pipa']) ;
$canvas->addtag("id$id", 'withtag', $id) ;

result: I create the text, Tk::Canvas assigns id for example equal to 1234,
and I store it in the tag 'id1234' assigned to the text. So that when the
text is clicked I know for sure which, precisely, text has been clicked
(no, tag 'current' is not enough).

Yes, I could have assigned my own unique tags. But what for, pray?

j.

--
------------ January Weiner 3 ---------------------+---------------
Division of Bioinformatics, University of Muenster | Schloßplatz 4
(+49)(251)8321634 | D48149 Münster
http://www.uni-muenster.de/Biologie.Botanik/ebb/ | Germany
January Weiner

2006-02-10, 6:58 pm

zentara <zentara@highstream.net> wrote:

[color=darkred]
> my $id = $canv->find(qw/withtag current/);
> my (@ids) = $canv->find(qw/withtag foobar/);


This gives me the associated tags, but not the unique id.

[color=darkred]
> Zinc does this easily, and if you are using linux, you don't need
> Postscript output to get a screenshot. Use Tk::WinPhoto.


Bitmaps are no good. For publication-ready, perfect illustrations you need
real Postscript, otherwise your figures blow up to hundreds of megabytes
(at 600dpi for example) and often still look like crap. If I do not have
automated Postscript output, I need to generate it myself. I have been
doing it a lot and I hate it. I love the fact that I get WYSIWYG
Postscript with Tk::Canvas.

> The postscript output of a Tk::Canvas is some sort of bitmap anyways,
> a jpg would be just as good.


No, as far as I can tell, it is not.

> And although it is heresy to say it here, you might want to
> look at Gtk2, which uses Pango and Cairo, and can do rotated text.


Apart from the fact that it lacks the Postscript method, gtk2 is not
generally a bad idea, I think. Ported to other platforms. Could be a good
idea to try it. I wonder whether there are huge differences in the speed
and reactivity of the interface.

And the other two... I know Cairo -- it's a city in Egypt, but what is
Pango? :-)

Thanks for your answer!

j.

--
------------ January Weiner 3 ---------------------+---------------
Division of Bioinformatics, University of Muenster | Schloßplatz 4
(+49)(251)8321634 | D48149 Münster
http://www.uni-muenster.de/Biologie.Botanik/ebb/ | Germany
Ch Lamprecht

2006-02-10, 6:58 pm

January Weiner wrote:
>
>
>
>
> Yeah, I know, what I meant was: I add the tag equal to the id to eventually
> get the real, unique id when I need it:
>
> my $id = $canvas->createText($x, $y, -text=>"blah", -tags=>['one', 'text', 'pipa']) ;
> $canvas->addtag("id$id", 'withtag', $id) ;
>
> result: I create the text, Tk::Canvas assigns id for example equal to 1234,
> and I store it in the tag 'id1234' assigned to the text. So that when the
> text is clicked I know for sure which, precisely, text has been clicked
> (no, tag 'current' is not enough).
>


Sorry there was a mistake in my code. Tag 'current' should be enough.
Try this one.

I used
my $id =($canvas->find('withtag','current'))[0];
frequently and never encountered problems with it.
Am I missing something??




use strict;
use warnings;
use Tk;

my $mw = tkinit;
$mw->Label(-text=>'click on an item to print its id')->pack;
my $canvas = $mw->Canvas()->pack;
for (1..15){
my @tags = (($_<5?'my_tag':'my_tag2'),($_%2?'my_tag3':'my_tag4'));
my $id = $canvas->createText(20,$_*15, -anchor=>'w',
-text=>"item $_ associated with tags @tags");
for (@tags){$canvas->addtag($_, 'withtag',$id)};
}
for ('my_tag','my_tag2','my_tag3','my_tag4')
{
my $tag = $_;
$mw->Button(-text=>"get ids for $tag",
-command=>sub{
print join("\n",$canvas->find(withtag=>$tag),"\n");
flash($tag);
})->pack;
}

$canvas->bind ('all','<1>',\&get_current);
MainLoop();

sub flash{
my $tag = shift;
$canvas->itemconfigure($tag,-fill=>'red');
$mw->after(1000,
sub{$canvas->itemconfigure($tag,-fill=>'black')});
}
sub get_current{
print "\ncurrent item:\n";
my $id =($canvas->find('withtag','current'))[0];
print "$id\n";
flash($id);
}
__END__

Christoph
--

perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"
January Weiner

2006-02-10, 6:58 pm

Ch Lamprecht <christoph.lamprecht.no.spam@web.de> wrote:
> Am I missing something??


Nope. Except that you have duplicate the id in a new tag. Look, the whole
matter starts being academic :-) I just thought that there is a simple way
of getting the actual id of an item and that I cannot find it in the
documentation. I thought of something like

$the_real_uniqe_id_canvas_assigned_to_th
e_item = $canvas->getid('current') ;

There appears to be none, so the matter is closed :-)

Thanks anyway,

j.


--
------------ January Weiner 3 ---------------------+---------------
Division of Bioinformatics, University of Muenster | Schloßplatz 4
(+49)(251)8321634 | D48149 Münster
http://www.uni-muenster.de/Biologie.Botanik/ebb/ | Germany
zentara

2006-02-10, 6:58 pm

On Fri, 10 Feb 2006 15:49:08 +0100 (CET), January Weiner
<january.weiner@gmail.com> wrote:

>zentara <zentara@highstream.net> wrote:
>
>
>
>This gives me the associated tags, but not the unique id.


Did you read the output of the example? The ids are displayed
as 1 and 2, which are different from the tags red,blue,current.

The 1 and 2 are the unique ids that the canvas assigns.


>
>No, as far as I can tell, it is not.


Ok, postscript is better. :-)

>
>
>Apart from the fact that it lacks the Postscript method, gtk2 is not
>generally a bad idea, I think. Ported to other platforms. Could be a good
>idea to try it. I wonder whether there are huge differences in the speed
>and reactivity of the interface.


Gtk2 is faster, and generally superior. It has a consistent object
style, and pango lets you do all sorts of things like html markup.
So you can have a label, with First word font1 with red fg and black bg,
while word2 is different.

$label_w_markup->set_markup("<span foreground=\"yellow1\"
size=\"40000\">Label with</span><s><big> Tango </big></s> Pango
<span background = 'black' foreground= 'green' size
='30000'><i>markup</i></span>");


It is very powerful and configurable, therefore is a bit harder to
learn, but once you get used to handling all the details, its easier
because you can control every little aspect of the way the script runs.

>
>And the other two... I know Cairo -- it's a city in Egypt, but what is
>Pango? :-)

See
http://pango.org/
and it has links to Cairo.

Cairo supports pdf, ps output etc. There are Perl/Gtk2 interfaces
to this Gtk2 stuff, and there is an excellent tutorial at
http://forge.novell.com/modules/xfc.../documentation/

it's sample programs contains an example of rotating text in a label.
gtk2_label.pl

The perl Gtk2 bindings are at
http://sourceforge.net/project/show...?group_id=64773

Cairo is a dependency which you should install before building
the libs. What you basically do is install the Gtk2 c-libs first in the
order Cairo, Glib,Pango,Atk,Gtk2

Then you have the basic setup. Then you install the corresponding
Perl bindings.

They are very active and updates come monthly.

>
>Thanks for your answer!


You are welcome.


--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
Ch Lamprecht

2006-02-10, 6:58 pm

January Weiner wrote:
> Ch Lamprecht <christoph.lamprecht.no.spam@web.de> wrote:
>
>
>
> I just thought that there is a simple way
> of getting the actual id of an item and that I cannot find it in the
> documentation. I thought of something like
>
> $the_real_uniqe_id_canvas_assigned_to_th
e_item = $canvas->getid('current') ;
>
> There appears to be none, so the matter is closed :-)


Can you give me an example for

my $id =($canvas->find('withtag','current'))[0];

not returning "the real unique id canvas assigned to the item"??

regards,
Christoph

--

perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"
January Weiner

2006-02-10, 6:58 pm

Ch Lamprecht <christoph.lamprecht.no.spam@web.de> wrote:
> Can you give me an example for


> my $id =($canvas->find('withtag','current'))[0];


> not returning "the real unique id canvas assigned to the item"??


Huh. Hm.... I think I need to apologize. Sorry. My mistake. I am all
. You are right. Uh. Punish me. Oh no, don't do it, I have
already wasted lots of time by not understanding what has been told me,
this is punishment enough :-)

j.


--
------------ January Weiner 3 ---------------------+---------------
Division of Bioinformatics, University of Muenster | Schloßplatz 4
(+49)(251)8321634 | D48149 Münster
http://www.uni-muenster.de/Biologie.Botanik/ebb/ | Germany
Ala Qumsieh

2006-02-10, 6:58 pm

blah@gmail.com wrote:

> Ala Qumsieh <notvalid@email.com> wrote:
>
>
> Nope. This does not return the ids, but the tags only. (it _should_,
> however, return the tag as well, as this would be consistent with the
> "tagOrId" thinking).


I'm not sure I understand. The find() method *will* return the object ids of
all the objects meeting the given criteria. If you want to find the tags of
an object, you would then use:

for my $id (@ids) {
my @tags = $canvas->gettags($id);
# ...
}

--Ala

January Weiner

2006-02-13, 6:59 pm

Ala Qumsieh <noreply@invalid.net> wrote:
> I'm not sure I understand. The find() method *will* return the object ids of


I'm sorry, I got the answers to my questions, but was and started
arguing. Actually, I the method gettags with the find method.

Sorry.
j.

--
------------ January Weiner 3 ---------------------+---------------
Division of Bioinformatics, University of Muenster | Schloßplatz 4
(+49)(251)8321634 | D48149 Münster
http://www.uni-muenster.de/Biologie.Botanik/ebb/ | Germany
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com