re: position of a widget?

Thanks for the code Zentara. I now have managed to get drag and drop
working from my table that holds thumb nails of images, dropped into
the canvas. I can also move around the images in the canvas and I've
added a function for snapping the image's border each other. Nice!

I was trying to sort the images based on their x values on the canvas,
for various reasons. Obviously, I lack some fundamental perl skills
since I can't get this to work. My plan was to
put my canvas items in a hash together with their x value, sort the
hash based on the value and the move them around based on the result
form the sort.
It all works pretty well, except that I can't figure out how to store
a canvas item in a hash and call it later when I want to move it.

Please consider this snippet of code:

@textArray = ("a", "b", "c", "d");
my $counter = 0;
my %textHash = ();

foreach (@textArray){

        #create a text item
        my $text = Gnome2::Canvas::Item->new ($root, 'Gnome2::Canvas::Text',
                             x => $counter,
                             y => 15,
                             fill_color => 'black',
                             font => 'Sans 14',
                             anchor => 'GTK_ANCHOR_NW',
                             text => '$_');

     #store text item together with its x value in the hash
    $imageHash{$text}  = $counter;


# loop through the hash and do something
# (in this case move())

for my $key ( keys %textHash  ) {
    my $value = $textHash{$key};
    my $newX = $value + 10;
    $key->move($newX, 0);

This code above shows what I'm trying to do. When I call $key->move()
I get an error saying move() is not a part of $key.

I hope this make sense, if not, I'll try to explain better.
Any ideas what I'm missing?

Thanks heaps!


On 17/09/2007, zentara <zentara1 sbcglobal net> wrote:

Well, the canvas will always be there, and it works. There has been some improvements
recently, like dashed line support.
Frozen development, dosn't mean being deprecated.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]