#!/usr/bin/perl use Tk; use Tk::HList; require Tk::ItemStyle; $top = new MainWindow; $top->ItemStyle( 'text', -stylename => 'red', #uncomment the following line to see the anchor change -anchor => 'e', -fg => 'red', -bg => 'black', ); $top->ItemStyle( 'text', -stylename => 'blue', -fg => 'blue', -bg => 'lightyellow', ); $top->ItemStyle( 'text', -stylename => 'cyan', -fg => 'cyan', ); $top->ItemStyle( 'text', -stylename => 'green', -fg => 'green', ); $hlist = $top->Scrolled( "HList", -header => 1, -columns => 4, -scrollbars => 'osoe', -width => 70, -selectbackground => 'SeaGreen3', )->pack( -expand => 1, -fill => 'both' ); $hlist->header( 'create', 0, -text => 'A', -style => 'red' ); $hlist->header( 'create', 1, -text => 'B', -style => 'blue' ); $hlist->header( 'create', 2, -text => 'C', -style => 'cyan' ); $hlist->header( 'create', 3, -text => 'D',-style => 'green' ); $hlist->add(0); $hlist->itemCreate( 0, 0, -text => "abc", -style => 'red' ); $hlist->itemCreate( 0, 1, -text => "def", -style => 'blue' ); $hlist->itemCreate( 0, 2, -text => "ghi", -style => 'cyan' ); $hlist->itemCreate( 0, 3, -text => "jkl", -style => 'green' ); $hlist->add(1); $hlist->itemCreate( 1, 0, -text => "mnopg", -style => 'red' ); $hlist->itemCreate( 1, 1, -text => "pqr", -style => 'blue' ); $hlist->itemCreate( 1, 2, -text => "stu", -style => 'cyan' ); $hlist->itemCreate( 1, 3, -text => "vwx", -style => 'green' ); $hlist->columnWidth(0, ''); $hlist->columnWidth(1, ''); $hlist->columnWidth(2, ''); $hlist->columnWidth(3, ''); MainLoop();
In reply to Re: LIst box selection using up and down arrow key
by zentara
in thread LIst box selection using up and down arrow key
by YGP
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |