yyqdian has asked for the wisdom of the Perl Monks concerning the following question:

#!/usr/bin/perl #2014/1/23-16:7:4 use warnings; use Glib qw{ TRUE FALSE }; use Gtk2 '-init'; my $builder; my $window; # get a new builder object $builder = Gtk2::Builder->new(); # load the Gtk File from GLADE $builder->add_from_file( "test.glade" ) or die "Error loading GLADE file"; # create the main window $window = $builder->get_object( "window1" ) or die "Error while creating Main Window"; #my $button1 = $gladexml->get_widget('button1'); $button1 = $builder->get_object( "button1" ); $label1 = $builder->get_object( "label1" ); $liststore1 = $builder->get_object( "liststore1" ); $treeview1 = $builder->get_object( "treeview1" ); $treeviewcolumn1 = $builder->get_object( "treeviewcolumn1" ); $treeviewcolumn2 = $builder->get_object( "treeviewcolumn2" ); #treeview1 #gtk_tree_view_column_pack_end #$button1-> signal_connect( clicked => sub{Gtk2->main_quit;}); $liststore1->set($liststore1->append,0, 12, 1, 12); #$liststore1->set($liststore1->append,1, "12", 2, "12"); $button1-> signal_connect( clicked => sub{$label1->set_label("nihao"); +}); sub gtk_main_quit { Gtk2->main_quit();} #$nihao="ddd"; # connect the event handlers #$builder->connect_signals( undef ); $builder->connect_signals(clicked => sub{Gtk2->main_quit;},$button1 ); $window->show_all(); $builder = undef; Gtk2->main(); exit; ================test.glade=================== <?xml version="1.0" encoding="UTF-8"?> <interface> <requires lib="gtk+" version="2.24"/> <!-- interface-naming-policy project-wide --> <object class="GtkListStore" id="liststore1"/> <object class="GtkWindow" id="window1"> <property name="can_focus">False</property> <child> <object class="GtkFixed" id="fixed1"> <property name="visible">True</property> <property name="can_focus">False</property> <child> <object class="GtkButton" id="button1"> <property name="label" translatable="yes">button</property +> <property name="width_request">100</property> <property name="height_request">37</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <signal name="destroy-event" handler="gtk_main_quit" swapp +ed="no"/> <signal name="destroy" handler="gtk_main_quit" swapped="no +"/> </object> <packing> <property name="x">250</property> <property name="y">124</property> </packing> </child> <child> <object class="GtkButton" id="button2"> <property name="label" translatable="yes">button</property +> <property name="width_request">100</property> <property name="height_request">80</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> </object> <packing> <property name="x">176</property> <property name="y">195</property> </packing> </child> <child> <object class="GtkTreeView" id="treeview1"> <property name="width_request">218</property> <property name="height_request">108</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="model">liststore1</property> <property name="search_column">3</property> <child> <object class="GtkTreeViewColumn" id="treeviewcolumn1"> <property name="resizable">True</property> <property name="title" translatable="yes">&#37722;&#23 +941;&#29927;</property> <property name="reorderable">True</property> <property name="sort_indicator">True</property> <property name="sort_column_id">0</property> <property name="text">0</property> </object> </child> <child> <object class="GtkTreeViewColumn" id="treeviewcolumn2"> <property name="resizable">True</property> <property name="title" translatable="yes">&#39582;&#25 +774;&#32222;</property> <property name="reorderable">True</property> <property name="sort_indicator">True</property> <property name="sort_column_id">1</property> <property name="text">1</property> </object> </child> </object> <packing> <property name="x">26</property> <property name="y">42</property> </packing> </child> <child> <object class="GtkLabel" id="label1"> <property name="width_request">100</property> <property name="height_request">80</property> <property name="visible">True</property> <property name="can_focus">False</property> <property name="label" translatable="yes">label</property> </object> <packing> <property name="x">244</property> <property name="y">45</property> </packing> </child> </object> </child> </object> </interface>

Replies are listed 'Best First'.
Re: Why treeview shows no content?
by Discipulus (Canon) on Jan 29, 2014 at 11:37 UTC
    Welcome to the monastery.
    I moved this from PerlMonks discussion to Seekers of Perl Wisdom (ie questions).

    Consider read something about the use of this site on the Tutorials section: rigth sections to post questions, and how to ask.

    hth
    L*
    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
      I think about the tutorial treeview aspects tkx
Re: Why treeview shows no content?
by zentara (Cardinal) on Jan 29, 2014 at 12:55 UTC
    Can you make it work without using Glade? Provide a simple stand-alone example?

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
      $liststore1->set($liststore1->append,1, "12", 2, "12"); Above this code is not shown. Why
Re: Why treeview shows no content?
by GotToBTru (Prior) on Jan 29, 2014 at 14:21 UTC

    Is it an xpath problem?

      Might be. I do not know why the  $ liststore1-> set ($ liststore1-> append, 1, "12", 2, "12"); No Show
        Dear yyqdian
        after many years passed here and many questions asked permit me to suggest you to follow theese guidelines:

        Try, when is possible, to show the minimum code necessary to reproduce the problem you are experiencing. Many times, doing this, you'll discover a 'type 0' problem (the problem does not exists). In other cases monks will have something to explain you or to work with.

        Try to be less telegraphic in your descriptions and questions. Many monks here, and maybe we too, are not english native, so simple sentences and clear words are more easy worldwide understood.

        If someone propose a solution, before reposting, try it and show the results of the test.

        Hth

        L*
        There are no rules, there are no thumbs..
        Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.