如何检查Python中的Gtk.ListStore是否为空?

How to check if a Gtk.ListStore is empty in Python?

我想用 if 语句检查我的 Gtk.ListStore 是否为空。这意味着,上面没有行。我正在使用 Gtk+3 和 Python 3.5.2。谢谢

Gtk.ListStore implements the interface Gtk.TreeModel. You can use get_iter_first 检查商店是否为空。

使用python,也可以使用len()的方法来检查store的大小,如果为0(零),则为空。例如:

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

商店的大小等于行数:

nrows=len(store)