Reputation: 10024
I'm trying to add Tree View to my PyGTK app.
Here is how it looks in Glade:
And there is the main window code where I'm trying to add append some data to my Tree View:
import gettext
from gettext import gettext as _
gettext.textdomain('repository-notifier')
import gtk
import logging
logger = logging.getLogger('repository_notifier')
from repository_notifier_lib import Window
from repository_notifier.AboutRepositoryNotifierDialog import AboutRepositoryNotifierDialog
from repository_notifier.PreferencesRepositoryNotifierDialog import PreferencesRepositoryNotifierDialog
# See repository_notifier_lib.Window.py for more details about how this class works
class RepositoryNotifierWindow(Window):
__gtype_name__ = "RepositoryNotifierWindow"
def finish_initializing(self, builder): # pylint: disable=E1002
"""Set up the main window"""
super(RepositoryNotifierWindow, self).finish_initializing(builder)
self.AboutDialog = AboutRepositoryNotifierDialog
self.PreferencesDialog = PreferencesRepositoryNotifierDialog
# Code for other initialization actions should be added here.
self.builder.get_object('listLogModel').append([5])
self.builder.get_object('listLogModel').append([6])
self.builder.get_object('listLogModel').append([7])
But empty Tree View is what I get when I run the app:
Same happens when I add rows to Tree View from Glade.
What am I doing wrong?
Upvotes: 1
Views: 401
Reputation: 40424
I think you need to add a TreeViewColumn
under your ListStore
with some CellRenderer
to display the column you already have in the model.
To do that, select the TreeView
widget and click on the Edit
button. A dialog will be opened (similar to the one used to edit menus) so that you can add columns and renderers to the columns. After that, any changes in the model will be displayed in the treeview.
Upvotes: 2