Tk::DHList - A HList widget with a visible/hidden data column |
Tk::DHList - A HList widget with a visible/hidden data column
use Tk; use Tk::DHList
my $mw = MainWindow->new();
#my $listbox = $mw->DHList( my $listbox = $mw->Scrolled('DHList', -scrollbars => 'e', -cursor => 'right_ptr', -relief => 'sunken', -borderwidth => '2', -width => '10', # columns -height => '15', # lines -background => 'orange', -selectmode => 'single', -sizecmd => \&size_cb, #new options -viewtype => 'withdata', -datastyle => $datastyle; -databackground => 'skyblue', -numeric_primary_sort => '0', -numeric_secondary_sort => '1', )->pack;
Tk::MainLoop; sub add_data { # 1) insert a complete array with texts and data, keys become 'visible' entry, # values are stored as data and are shown in transient column. $listbox->add($key, -data => 'i02', -itemtype => 'imagetext', -text => 'Dummy', -image => $xpms{dummy}, #-datastyle => $datastyle, ); } sub size_cb { print "we have resized\n"; }
A HList derived widget that offers several add-on functions like sorting, reordering and inserting/retrieving of item text & data, suitable for perl Tk800.x (developed with Tk800.024).
You can insert item-texts or item-text/-value pair/s into the DHList widget with the standard-like add() method . The delete removes visible list-items as well as the associated data.
get_item(), get_item_text(), get_item_value() retrieve either a scalar or lists, depending on the context it was invoked. In scalar mode they return the first item only (/first item-text/-text/-value/). In list context they return the text AND the belonging data.
getcurselection(), getcurselection_text(), getcurselection_value(), and getcurselection_index() also retrieve either a scalar or a list, depending on the context but for the currently selected listitem. For scalar mode same rule applies as for get_item.
reverse() reverses the whole list and all item values.
sort() sorts the whole list (alpha)numerical and reorders all entries. Depending on the sortmode either the first column content or the data column content is used as the searchkey.
viewtype() might be invoked directly or via configure to switch between 'withdata' or 'normal' listbox view.
If the Listbox has the input focus the key 'Control-Key-[' makes the data-list visible and 'Control-Key-]' hides it.
sort()
function (numeric on primary keys / first column).
sort()
function (numeric on secondary keys / data column).
add()
function
$list->add( -text => 'Entry|Col2|col3|col4', ... );
Michael Krause, KrauseM_AT_gmx_DOT_net
This code may be distributed under the same conditions as Perl.
V2.1 (C) Sept 2009
Tk::DHList - A HList widget with a visible/hidden data column |