Next / Previous / Contents / Shipman's homepage

5.8. ScrolledList.count(): Return the line count

This method returns the number of lines currently in use inside the listbox. The .size() method on the Listbox widget is exactly what we need.

Note

Originally I wanted to define a .__len__() method so that the user could use the Python len() function on a ScrolledList to get the line count. However, this caused some bizarre bugs, so it is now a conventional method.

scrolledlist.py
    def count(self):
        """Return the number of lines in use in the listbox.
        """
        return self.listbox.size()