Copyright © 2008, 2009 Arndt Roger Schneider
The Rtl_mlistbox is a multi column listbox. It is composed out of discreet listboxes, or any other control satisfying the listbox interface. The listbox-type is specified through the static –cannot be changed after creation– property »-listtype«. The »-listtype« default is the Tcl/Tk listbox. The given Rtl_mlistbox structure, with its replaceable listboxes supports a possible 'virtual listbox'. A 'virtual listbox' won’t hold any data itself, but has the knowledge to retrieve it on-demand. Separating data and visual representation is a prerequisite for dealing with volatile content –most apparent in a distributed environment. The same design principle applies to 'rtl_combobox'.
Figure 6.1, “Rtl_mlistbox with Hugelist” displays cascading Rtl_mlistboxes. Three Rtl_mlistboxes are embedded via »-listtype« inside a Rtl_mlistbox. The inner Rtl_mlistboxes feature hugelists version 1.4.
Example 6.1. A Two Column Listbox
# Scrollbars: rtl_gridwin .gridwin \ -widget .gridwin.listboxes rtl_mlistbox .gridwin.listboxes \ -listtype listbox \ -columns 2 \ -columnwidths {50 200} \ -headings {{Nr.} {Name}} \ -headingsanchor {e w} … # Map the gridwin on screen, pack .gridwin … .gridwin update
The Example 6.1, “A Two Column Listbox” produces a simple two-column Rtl_mlistbox with Tk’s listbox, resembling: Figure 6.2, “Rtl_mlistbox with Tk’s Listboxes”.
Items are dealt with in the same way as with a ordinary listbox –In fact, Rtl_mlistbox is composed of listboxes, hence it is even possible to directly access the internal listboxes. An item consist of a list of n-items ('n' = columns).
Example 6.2. Inserting and deleting Items
# Add items like with a normal listbox: .gridwin.listboxes insert end \ {{1} {Item One}} \ {{n} {Item Nth}}
Figure 6.3, “Inside a three column Rtl_mlistbox” displays the internal structure of a three-column Rtl_mlistbox. The elements »head_n«, »withhandle_n«, »withhandle_n_black« and »listbox_n« are dynamic template elements, were n is derived from the »-columns« property.