http://www.perlmonks.org?node_id=952088


in reply to Re^5: Insert checkbutton into MListbox
in thread Insert checkbutton into MListbox

This was really helpful. I was also thinking of using hash for storing and re-positioning the text items upon clicking on up and down button. I proceeded as below but a bit stuck. Let us assume I have put your code in a subroutine called build_layout()

my $dynamic_hash = {0 => "job",1=> "state",2 =>"dependencies",3=>"resu +lt"}; &build_layout($init_hash); sub build_layout { ## samething what u have sent foreach my $itemkey (sort keys %$dynamic_hash) { my $btn=$text->Checkbutton(%attr_item,'-activebackground'=>'#ff7f7 +f' ); my $up=$text->Button(-text=>'Up',%attr_btn, -command => [\&moveup, +${$dynamic_hash}{$itemkey} ); my $down=$text->Button(-text=>'Down',%attr_btn,)-command => [\&mov +edown,${$dynamic_hash}{$itemkey}; ..... ..... $text->insert('1.0',sprintf('%-'.$item_width.'s',${$dynamic_hash}{ +$itemkey})); } sub moveup { my $text = shift ### not able to proceed here } sub movedown { }