treeview looks like a list not as a tree

View: New views
4 Messages — Rating Filter:   Alert me  

treeview looks like a list not as a tree

by anguila :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi
I dont understand why in my treeview looks like a list and not as a tree, i have added a parent in each set and the child doesnt added:



I have a sub. to create the treeview:

sub crear_llista_links{
    my $tree_view= $programa->get_widget('llista_links');
    $tree_store = Gtk2::TreeStore->new(qw(Glib::String Gtk2::Gdk::Pixbuf Glib::Double));
    $tree_view->set_model($tree_store);

    my $tree_column = Gtk2::TreeViewColumn->new();

    my $link= Gtk2::CellRendererText->new;
    my $pixbuf= Gtk2::CellRendererPixbuf->new();
    my $pbar = Gtk2::CellRendererProgress->new();
    $tree_column->pack_start($link,0);
    $tree_column->pack_start($pixbuf,0);

    $tree_column->set_attributes($link,'text'=>0);
    $tree_column->set_attributes($pixbuf,'pixbuf'=>1);

    my $tree_column2 = Gtk2::TreeViewColumn->new();
    $tree_column2->pack_start($pbar,0);
    $tree_column2->set_attributes($pbar, 'value' => 2);

    $tree_view->append_column($tree_column);
    $tree_view->append_column($tree_column2);

    return $tree_store;
}


and there in a piece of code i use that:
...
                my $obj= $tree_store->append(undef);

                $tree_store->set($obj,0=>$def_link, 1=>$logo_server);
                my $child= $tree_store->append($obj);
                $tree_store->set($fill,0=>"CHILD",1=>$logo_server);
....


$obj is the parent and after i make a child of this parent and set it the text value to CHILD, but this set doesnt added at the list, and i dont really understand why..
Any idea?

Thanks.

David


_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@...
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

Re: treeview looks like a list not as a tree

by Emmanuel Rodriguez :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Thu, Jul 23, 2009 at 9:46 PM, anguila <anguila@...> wrote:
Hi
I dont understand why in my treeview looks like a list and not as a tree, i have added a parent in each set and the child doesnt added:

and there in a piece of code i use that:
...
                my $obj= $tree_store->append(undef);

                $tree_store->set($obj,0=>$def_link, 1=>$logo_server);
                my $child= $tree_store->append($obj);

Try to see if you replace this line:

                $tree_store->set($fill,0=>"CHILD",1=>$logo_server);

With :
$tree_store->set($child,0=>"CHILD",1=>$logo_server);

--
Emmanuel Rodriguez

_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@...
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

Re: treeview looks like a list not as a tree

by anguila :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, in my code was here, sry, I traduced the variables to b more readable.
So the problem still exist, i defined relation with child and parent and doesnt looks like a tree..

On Thu, Jul 23, 2009 at 10:53 PM, Emmanuel Rodriguez <emmanuel.rodriguez@...> wrote:


On Thu, Jul 23, 2009 at 9:46 PM, anguila <anguila@...> wrote:
Hi
I dont understand why in my treeview looks like a list and not as a tree, i have added a parent in each set and the child doesnt added:

and there in a piece of code i use that:
...
                my $obj= $tree_store->append(undef);

                $tree_store->set($obj,0=>$def_link, 1=>$logo_server);
                my $child= $tree_store->append($obj);

Try to see if you replace this line:

                $tree_store->set($fill,0=>"CHILD",1=>$logo_server);

With :
$tree_store->set($child,0=>"CHILD",1=>$logo_server);

--
Emmanuel Rodriguez


_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@...
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

Re: treeview looks like a list not as a tree

by Emmanuel Rodriguez :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Fri, Jul 24, 2009 at 1:17 AM, anguila <anguila@...> wrote:
Yes, in my code was here, sry, I traduced the variables to b more readable.
So the problem still exist, i defined relation with child and parent and doesnt looks like a tree..
Could you try to isolate the code in a small working program that demonstrates the problem? Otherwise it will be very hard for us to find what's going wrong.

Here's how I was once filling a tree:

http://code.google.com/p/xacobeo/source/browse/tags/0.04/lib/Xacobeo/DomModel.pm#90

The important part is to call $child = $model->append($parent); and to keep $child as the parent iter whenn adding it's children. If you fail to keep $child (if it's set to undef) you will be simply adding elements to the top of the tree and creating a flat list.

Perhaps your $iter is always undef?
 
--
Emmanuel Rodriguez

_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@...
http://mail.gnome.org/mailman/listinfo/gtk-perl-list