Listboxes

I’ve been frustrated by Blender Python’s lack of anything like TKinter’s scrolling listboxes, so I’ve put together a listbox for my own use. The script at the link, below, is a stripped-down example of implementation.

I’m new at Python and fairly new at programming, so i can’t vouch for the “correctness” of my code. This could possibly help give someone else a sense of how to do some things if they ever need a listbox, however. So, be warned: this is newbie code which probably doesn’t live up to the proposed scripting guidelines. Don’t adapt this directly and don’t copy my errors if you are, like me, still learning.

If anyone who does know the correct way of doing things wants to try to clean this up, it might provide the foundation of a listbox that others can advisably use. I’ll try to fix any problem points, if I’m made aware of them.

the example lacks a scrollbar. The few examples I could find of BPy scrollbars didn’t handle as well as I would have liked, so I didn’t bother to try to make one. Instead, it uses either the mouse wheel or a slider bar.

There are two implementations in the example. One shows file browsing and selection (which is apparently, in itself, in breach of the proposed guidelines); the other illustrates multiple selections using the pose bones list. you need to have a selected armature in your scene to use the pose bones example. Multiple selection returns a list which can be used by other functions. The list prints out in the console, if you want to inspect it.

http://www.kuroyumes-developmentzone.com/~Cage/listbox2.py

(Edited to repair the fact that I’m typing like a two-day-old baby roach.)