[PyQt] pyqt behavior change

Ingrid Dahl-Olsen id at dneg.com
Wed Aug 24 12:51:52 BST 2011


Hi,

Sorry for commenting on a post this old, but I've only just run into 
this change as I'm using PyQt in maya at work, and so have been stuck 
with using 4.7.2 until very recently when it was bumped up to 4.8.4.

Just out of curiosity, is it really wrong to expect an instance of a 
widget like QComboBox to evaluate to True? I can understand the 
implementation of the __len__ method as a neater, more pythonic way to 
test for number of items in the widget (although personally, I think 
just using count() is a bit clearer). But does that really mean it makes 
sense to evaluate to False if there are no items in the combo box? It's 
still a widget with attributes etc, which potentially takes up screen 
space. I would have thought the __nonzero__ method should also have been 
implemented, so 'if combo' would still evaluate to True, but len( combo 
) would return 0?

I expect this behaviour will stay as it is, as it's been that way for a 
year now, but just thought I'd ask...

Cheers,
Ingrid


More information about the PyQt mailing list