PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, October 28, 2022

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

 October 28, 2022     gtk3, is-empty, python-3.x     No comments   

Issue

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.


Solution

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)


Answered By - José Fonte
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing