Missing text in GUI (PyGObject)
Question: I have created a GUI with pyGObject using a xml description file and I'm
trying to create a sidebar with `GtkTreeView`. `GtkTreeView` doesn't show
_any_ text in the headers and children in my GUI even though I have added
some. Why is that? How can I fix it?

The sidebar should have shown the following:

    
    
    Parent 1
        Child 1
        Child 2
        Child 3
    

etc.

A short version of my code is shown below.

**App.py**

    
    
    #!/usr/bin/env python2
    
    from gi.repository import Gtk
    
    
    class AppUI:
        def __init__(self):
            self.builder = Gtk.Builder()
            self.builder.add_from_file("app.xml")
            self.window = self.builder.get_object("main-window")
            self.sidebarStore = self.builder.get_object("sidebar-store")
    
            for parent in range(4):
                piter = self.sidebarStore.append(None, ['parent %i' % parent])
                for child in range(3):
                    self.sidebarStore.append(piter, ['child %i of parent %i' % (child, parent)])
            self.handlers = {
                "onDeleteWindow": Gtk.main_quit,
            }
            self.builder.connect_signals(self.handlers)
    
            self.window.show_all()
    
    UI = AppUI()
    Gtk.main()
    

**app.xml: UI description**

    
    
    <?xml version="1.0" encoding="UTF-8"?>
    <interface>
        <object class="GtkTreeStore" id="sidebar-store">
            <columns>
                <column type="gchararray"/>
            </columns>
        </object>
        <object class="GtkWindow" id="main-window">
            <property name="title"></property>
            <signal name="delete-event" handler="onDeleteWindow"/>
            <child>
                <object class="GtkBox" id="container">
                    <property name="orientation">horizontal</property>
                    <child>
                        <object class="GtkTreeView" id="sidebar">
                            <property name="model">sidebar-store</property>
                            <property name="headers-visible">false</property>
                            <child>
                                <object class="GtkTreeViewColumn" id="test-column">
                                    <child>
                                        <object class="GtkCellRendererText" id="test-renderer"/>
                                    </child>
                                </object>
                            </child>
                        </object>
                    </child>
                    <child>
                        <object class="GtkBox" id="right-container">
                            <property name="orientation">vertical</property>
                            <child>
                                <object class="GtkButtonBox" id="top-buttonbox">
                                    <child>
                                        <object class="GtkButton" id="add-button">
                                            <property name="label">Add</property>
                                        </object>
                                    </child>
                                    <child>
                                        <object class="GtkButton" id="delete-button">
                                            <property name="label">Delete</property>
                                        </object>
                                    </child>
                                </object>
                            </child>
                        </object>
                    </child>
                </object>
            </child>
        </object>
    </interface>
    


Answer: Quite easy, you didn't mapped any column to the text renderer.

BTW, what editor are you using for creating the UI? Are you writting it by
hand? Use Glade, life is easier that way.

In Glade, right click the TreeView -> Edit -> Hierarchy -> Select Cell
Renderer -> Text mapped to the column in the model.

Following is the corrected version of the XML edited through Glade. The most
relevant part is:

    
    
    <attributes>
        <attribute name="text">0</attribute>
    </attributes>
    

When you defined the text cell renderer.

    
    
    <?xml version="1.0" encoding="UTF-8"?>
    <interface>
      <!-- interface-requires gtk+ 3.0 -->
      <object class="GtkTreeStore" id="sidebar-store">
        <columns>
          <!-- column-name gchararray -->
          <column type="gchararray"/>
        </columns>
      </object>
      <object class="GtkWindow" id="main-window">
        <property name="can_focus">False</property>
        <signal name="delete-event" handler="onDeleteWindow" swapped="no"/>
        <child>
          <object class="GtkBox" id="container">
            <property name="can_focus">False</property>
            <child>
              <object class="GtkTreeView" id="sidebar">
                <property name="width_request">100</property>
                <property name="can_focus">False</property>
                <property name="model">sidebar-store</property>
                <property name="headers_visible">False</property>
                <child internal-child="selection">
                  <object class="GtkTreeSelection" id="treeview-selection1"/>
                </child>
                <child>
                  <object class="GtkTreeViewColumn" id="test-column">
                    <child>
                      <object class="GtkCellRendererText" id="test-renderer"/>
                      <attributes>
                        <attribute name="text">0</attribute>
                      </attributes>
                    </child>
                  </object>
                </child>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkBox" id="right-container">
                <property name="can_focus">False</property>
                <property name="orientation">vertical</property>
                <child>
                  <object class="GtkButtonBox" id="top-buttonbox">
                    <property name="can_focus">False</property>
                    <child>
                      <object class="GtkButton" id="add-button">
                        <property name="label">Add</property>
                        <property name="use_action_appearance">False</property>
                        <property name="can_focus">False</property>
                        <property name="receives_default">False</property>
                        <property name="use_action_appearance">False</property>
                      </object>
                      <packing>
                        <property name="expand">False</property>
                        <property name="fill">True</property>
                        <property name="position">0</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="delete-button">
                        <property name="label">Delete</property>
                        <property name="use_action_appearance">False</property>
                        <property name="can_focus">False</property>
                        <property name="receives_default">False</property>
                        <property name="use_action_appearance">False</property>
                      </object>
                      <packing>
                        <property name="expand">False</property>
                        <property name="fill">True</property>
                        <property name="position">1</property>
                      </packing>
                    </child>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="fill">True</property>
                    <property name="position">0</property>
                  </packing>
                </child>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">1</property>
              </packing>
            </child>
          </object>
        </child>
      </object>
    </interface>
    

