1

I want to check with an if statement if my Gtk.ListStore is empty. This means, there are no rows on it. I am using Gtk+3 and Python 3.5.2. Thanks.

deko
  • 463
  • 1
  • 6
  • 17

1 Answers1

1

Gtk.ListStore implements the interface Gtk.TreeModel. You can use get_iter_first to check if the store it's empty.

With python, you can also use the len() method to check the size of the store, if 0 (zero), then it's empty. eg:

if (len(store)==0):
   #Empty
   ...
else:
   #NotEmpty
   ...

The size of the store equals the number of rows:

nrows=len(store)
José Fonte
  • 4,016
  • 2
  • 16
  • 28