>I was looking around for a listbox inside a window. I can't find any
>example such a thing (maybe I'm just overlooking it?). Mainly I want
>to position two listboxes (or scrollboxes or whatever you wanna call
>'m) within a single window.
There isn't any, but DirList is indeed a good example for how to build
one out of buttons and splits. Note, however, that all these
widget-type things were part of a project that I never finished (hence
the abhorring lack of documentation :-). One of the reasons was
indeed that it felt too slow to be useful in practice. Another reason
was that I never could invent a really simple programmer interface,
either with or without multiple inheritance. Maybe this widget stuff
isn't easy as I thought? The serious window systems [Andrew, X11,
Windows3.1] are all too big, and the small ones [e.g. Rob Pike's one
for Plan 9] suffer from lack of flexibility...
>% time Python TestDirList.py
>Time: 2:28.41 total 137.090 user 4.080 system 95.1% CPU
>IO: 59+1 io 391+3 r/w syscalls 0+0 raw r/w
>Mem: 0+14058 maj/min pf 137+344 incr/decr pff 0 max 187 zero 0 swaps
>Sys: 147+1 vol/invol ctxsw 2306 system calls 0 signals
I also played around with it a little and found this, opening 7 or 8
directories in a minute:
|& time python TestDirList.py
Now this is on a 33 MHz SGI Indigo, a real racing car. Is your
machine slow or memory-starved? (14058 minor page faults looks like a
lot to me).
On the other hand it could be that your realloc() implementation is
slow. If this is the case, building lists by appending elements to
the end one by one (as is done by os.listdir(), for example) may
become an O(n**2) matter since realloc() is copying the entire array
on each expansion. Most current malloc packages are cleverer than
that, so I didn't bother to try and optimize this in the Python code,
but if you're adventurous you could dive into the "listobject" source
code and somehow extend the array used to hold the list in larger
Of course, I'd try to profile python first, just to get more insight
(and yes, even on my system malloc is on top of the list).
--Guido van Rossum, CWI, Amsterdam <email@example.com>
"Anyone capable to get themselves elected president should on no
account be allowed to do the job."