sdaau
sdaau

Reputation: 38651

How to get the number of items / rows / length / count of gtk.ListStore

Consider this example:

import pygtk
pygtk.require('2.0')
import gtk

initarr = [ "aa", "bb", "xx" ]

liststore1 = gtk.ListStore(str)
for item in initarr:
  liststore1.append([item])

# one more:
liststore1.append(["whatever"])

# how to get length/size of liststore1 at this point?

As the comment says - how do I get the length / size of liststore1 at end of this code?

Upvotes: 1

Views: 2258

Answers (1)

Padraic Cunningham
Padraic Cunningham

Reputation: 180482

Just simply print len(liststore1)

To count particular items in a list:

l = ["foo","foo","bar"]
print l.count("foo")
2

Upvotes: 2

Related Questions