我正在尝试将树视图添加到我的PyGTK应用程序中。在
下面是它在空地上的样子:
在主窗口代码中,我尝试在树视图中添加附加数据:
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])
但是当我运行应用程序时,我得到的是空的树视图:
当我从Glade向树视图添加行时,也会发生同样的情况。在
我做错什么了?在
我认为您需要在您的}来显示模型中已有的列。在
ListStore
下添加一个TreeViewColumn
和一些{为此,选择
TreeView
小部件并单击Edit
按钮。将打开一个对话框(类似于用于编辑菜单的对话框),以便您可以向列添加列和渲染器。之后,模型中的任何更改都将显示在树视图中。在相关问题 更多 >
编程相关推荐