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.


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.
    def count(self):
        """Return the number of lines in use in the listbox.
        return self.listbox.size()