im trying to switch my application from python2.7 pyGTK to Python3 and pyGObject and having hard time with appending rows to my Gtk.ListStore :/
This code:
#!/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')
gives me always error:
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()
what is going on? How can I append new row into Gtk.ListStore?
Simply use the following command:
itr = store.append(['Its working', ])
You can find more example in The Python GTK+ 3 Tutorial.