PyGTK и Tree View - PullRequest
       14

PyGTK и Tree View

1 голос
/ 07 декабря 2011

Я пытаюсь добавить Tree View в мое приложение PyGTK.

Вот как это выглядит в Glade:

enter image description here enter image description here

И тамкод главного окна, в который я пытаюсь добавить и добавить некоторые данные в мое древовидное представление:

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])

Но пустое древовидное представление - это то, что я получаю при запуске приложения:

enter image description here

То же самое происходит, когда я добавляю строки в древовидное представление с поляны.

Что я делаю не так?

1 Ответ

2 голосов
/ 07 декабря 2011

Я думаю, вам нужно добавить TreeViewColumn под ListStore с некоторыми CellRenderer для отображения столбца, который у вас уже есть в модели.

Для этого выберите виджет TreeViewи нажмите на кнопку Edit.Откроется диалоговое окно (аналогичное тому, которое используется для редактирования меню), чтобы вы могли добавлять столбцы и средства визуализации к столбцам.После этого любые изменения в модели будут отображаться в виде дерева.

...