Version 28 of Virtuallist

Updated 2004-06-07 18:06:31

ulis a(Virtual)ListBox is a Tcl megawidget that displays a virtual list.

The idea of a virtual listbox was evoked early (1995) by Greg Goodman in c.l.t:

http://groups.google.com/groups?hl=fr&lr=&ie=UTF-8&frame=right&th=401f5a4fb1e3a888&seekm=3lcide%24l62%40Starbase.NeoSoft.COM#link1

I never read the thread before but his description is very close to my design.

http://perso.wanadoo.fr/maurice.ulis/tcl/Virtuallist/demo1.gif http://perso.wanadoo.fr/maurice.ulis/tcl/Virtuallist/demo3.gif http://perso.wanadoo.fr/maurice.ulis/tcl/Virtuallist/virtuallists.gif

The items are virtual and are obtained through a procedure callback when they should be displayed.

  • the list is not fixed and can vary on demand,
  • there can be more virtual items than memory can contain (until 2^30 - 1 items),
  • the items can be memorized to optimize the display,
  • the items can be invalidated to free the memory,
  • a note can be associated with each item.

doc & dowload: http://perso.wanadoo.fr/maurice.ulis/tcl/Virtuallist


See also


28 Sep, 2003 - How is it different from a (Tktable) table?

ulis: It's not a multi-columns megawidget but a widget with virtual data (given by a callback).

At the top of the page you can see:

  • the demo with computed items
  • the demo with items from the Web
  • the demo with items from a DB (3 associated virtuallists)

- Sorry, it still is not very clear.


LV It's very clear to me - and quite exciting. ulis, have you considered submitting your widgets to tklib for wider distribution?

ulis All my packages are under the NOL licence and there is no need for my permission to submit them to tklib.

LV ulis, while the license would permit the tklib maintainers to make use of your code, the Tcl community mindset is to try their hardest to involve the author in the process of making use of their code.

ulis Sorry, LV but I'm desengaging from Tcl. ... would you care to share why are you disengaging from Tcl?'


LV continued: As for the VirtualList, think of things this way. In most cases, a listbox contains a fixed set of data that you obtain up front, storing the values in at least the widget, if not additionally some sort of list variable.

However, with VirtualList, it sounds as if ulis uses callbacks, so that the data need not all be in memory - instead, it is fetched as you scroll further in the list.

- Now it is clear. Thank you.


Greg Goodman thread

  TK VIRTUAL LISTBOX WIDGET


  A virtual listbox is a listbox that presents an arbitrarily large list
  without keeping the entire list in memory.

  Instead of maintaining all the list entries, the virtual listbox maintains
  a smaller cache of list entries for presentation.  As the listbox's visible
  window moves, the contents of the cache are managed so that the visible 
  items are in memory.

  We modified the tkListbox.c source to produce tkVlistbox.c, which 
  implements a new Tk command, vlistbox.  The vlistbox command works
  just like the listbox command, except as follows:


  1. There are several additional configuration options.

     -cachesize

        This is the maximum number of elements maintained in memory at any
        one time.  It must be at least as large as the visible number of
        entries.  The default for the cachesize is 100.

     -numelements

        This is the total number of elements in the list.  We need this to
        properly position the thumb of the scrollbar.  

        This option is required.

     -getelementcommand

        This is a user-supplied script that supplies the string to be 
        displayed at any given position.  The script takes a single 
        parameter, a 0-based index.  It returns a list consisting of
        a return code and the string to be displayed at that index.

        the return code is:
           0 (TCL_OK) if everything is ok
           3 (TCL_BREAK) if the string is not available
           1 (TCL_ERROR) in any other case

        If the return code is 0, then the second element of the list
        is the string to be displayed.

        This option is required.


  2. There is an additional widget command, "flush", that tells the 
     vlistbox to dump its cache and repopulate it with calls to the user
     script.


  3. There is no insert or delete command.

     These are not necessary, since the list element for every position
     is provided, as needed, by a script.


  4. There is currently no multiple selection.

     We didn't need it right away, and haven't gotten around to it yet.


  To Do List

     1 Add multiple selection
     2 Add some more error handling (like missing required options)
     3 port to Tcl 7.4 / Tk 4.0


  How to get it.

     The virtual listbox package consists of a single source file
     (tkVlistbox.c), this documentation, instructions for installing it,
     and two simple demo scripts.

     For now, I will email a copy to anyone who requests it.  If there is
     enough demand, or when I've done a couple of the items on the 
     "To Do List" I'll submit it to alcatel.

  -- 
  Greg Goodman
  [email protected]
  <URL: http://starbase.neosoft.com/~gregg>

Category GUI

Category Widget