[PyKDE] Little Python helpers for PyQt

Jim Bublitz jbublitz at nwinternet.com
Thu Jan 22 06:16:00 GMT 2004


On Wednesday January 21 2004 16:58, Torsten Marek wrote:

> I think I can safely presume that anybody of you who has been
> working extensively with PyQt has created his/her own set of
> little helper functions that proved very useful in several
> projects of yours, because I see exactly that happening with
> me.
> For instance, I have several generator functions for walking
> listboxes and listviews (both shallow and deep) that I use
> very often.

> My proposal and the reason I write this email would be that
> each of you who thinks that he/she has a
> function/class/whatever of general interest posts those to the
> list, with code and some comment.
> Ongoing, we could create a small collection of pyqt-helpers
> which could then be downloaded from pykde.sf.net (or even
> included into PyQt, but that's completely up to Phil, who may
> forgive me my ambitions), to the benefit of us all.

> Since it's very late I will fully post my code tomorrow, but
> here's one iterator:

> def ListBoxIterator(listbox, selectedOnly = False):
>      i = listbox.firstItem()
>      while i:
>          if selectedOnly and not i.isSelected():
>              continue
>          yield i
>          i = i.next()
>      return
> It would also be possible to supply a filter function to the
> generator, what you could not do if QListBox would support the
> iterator protocol.

I think this is a great idea, and listboxes/listviews are a 
perennial topic here, so the that's a great choice too.

I'd be happy to include anything anyone wants to contribute along 
these lines for PyKDE with the PyKDE distribution - anything 
from small snippets like the iterator example above up to 
generalized application frameworks. Put your name on your work 
too.

Jim




More information about the PyQt mailing list