2013-02-17 46 views
1

我尝试从python2.7 PyGTK的我的应用程序切换到Python3和pyGObject以及具有附加行我Gtk.ListStore困难时期:/如何将行附加到Gtk.ListStore?

此代码:

#!/usr/bin/env python3 

from gi.repository import Gtk 

listStore = Gtk.ListStore(str) 
itr = Gtk.TreeIter() 
listStore.append(itr) 
listStore.set_value(itr, 0, 'Its working') 

给我总是错误:

Traceback (most recent call last): 
    File "./test.py", line 7, in <module> 
    listStore.append(itr) 
    File "/usr/lib/python3/dist-packages/gi/overrides/Gtk.py", line 1017, in append 
    return self._do_insert(-1, row) 
    File "/usr/lib/python3/dist-packages/gi/overrides/Gtk.py", line 1008, in _do_insert 
    row, columns = self._convert_row(row) 
    File "/usr/lib/python3/dist-packages/gi/overrides/Gtk.py", line 850, in _convert_row 
    if len(row) != n_columns: 
TypeError: object of type 'TreeIter' has no len() 

这是怎么回事?如何将新行添加到Gtk.ListStore中?

回答