Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9313163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:48:38+00:00 2026-06-19T01:48:38+00:00

I have created a GUI with pyGObject using a xml description file and I’m

  • 0

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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T01:48:39+00:00Added an answer on June 19, 2026 at 1:48 am

    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>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a GUI using java swing. From there I have
I have created my GUI using wxGlade and it looks fine in the display.
I have created a wizard using the GUI and so my pages are all
I have an assignment to create a GUI using MATLAB GUIDE and am having
I have recently been using WxPython to create a GUI Network simulator like Cisco
I am using swing to create my GUI. J have a JFrame containing one
I have GUI created using netbeans GUI builder. I want to add there an
I have created one GUI using Swing of Java. I have to now set
I have created a GUI in Java using swings with the help of Netbeans
I have created a Windows GUI program using C and the Windows API, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.