use strict; use warnings; use Tk; use Tk::HList; use Tk::ItemStyle; use Tk::BrowseEntry; use Tk::Toplevel; use Tk::Menubutton; my $sec = 10; my $data = { user1 => { "irun"=>{ "feature" => "queue", "vendor" => "abcd", "issued" => "100", "inuse" => 26 }, }, user2 => { "irun"=>{ "feature" => "queue", "vendor" => "abcd", "issued" => "510", "inuse" => 27 }, }, user2 => { "irun"=>{ "feature" => "batch", "vendor" => "pqrs", "issued" => "100", "inuse" => 222 }, }, user3 => { "irun"=>{ "feature" => "queue", "vendor" => "mnop", "issued" => "500", "inuse" => 244 }, }, user4 => { "irun"=>{ "feature" => "queue", "vendor" => "uvwx", "issued" => "400", "inuse" => 200 }, }, }; # Making the GUI my $mw = tkinit; # new MainWindow; $mw->title("gui"); $mw->geometry("480x160"); my $topframe = $mw->Frame(-width=>5,-height=>10)->pack(-side=>'top',-anchor=>'nw',-expand=>0); $topframe->Label(-text => "USER: user1")->pack(-side => 'left',-anchor => 'w',-padx => 0); $topframe->Label(-text => "Set time(sec)")->pack(-side => 'left',-anchor => 'w',-padx => 0); my $frequency = $topframe->Entry(-width=> 5,-textvariable=> \$sec)->pack(-side => 'left',-anchor => 'nw',-padx => 0); $topframe->Label(-text => "Select File")->pack(-side => 'left',-anchor => 'w',-padx => 0); #Help Menu my $menuButton = $topframe->Menubutton(-text => 'Help')->pack(-side=>'right'); my $menu = $menuButton->Menu (-tearoff => 0); my $user_manual = $menuButton-> cascade(-label => "Manual", -tearoff => 0); my $pref = $menuButton-> cascade(-label => "Preference", -tearoff => 0); $topframe->BrowseEntry( -state => 'normal', )->pack(-side=>'right',-anchor =>'e'); my $hlistframe = $mw->Frame()->pack(-fill => 'both',-expand=>1); my $hl; my $bottomframe = $mw->Frame()->pack(-fill => 'both', -expand => 0); $bottomframe->Button(-text => "Display File",-command => sub {})->pack(-side=>'right',-anchor => 'ne',-fill=>'x'); my ($general,$label1,$label2,$label3,$label4,$label5,$label6,$label7); $hl = $hlistframe->Scrolled('HList', -scrollbars => 'ose', -columns =>7 , -header => 1, -height => -1, )->pack(-fill => 'both',-expand =>1 ); $label1 = $hl->Label(-text => "Feature", -anchor => 'w'); $hl->headerCreate(0,-itemtype => 'window',-widget => $label1) ; $label2 = $hl->Label(-text => "Vendor", -anchor => 'w'); $hl->headerCreate(1,-itemtype => 'window',-widget => $label2); $label3 = $hl->Label(-text => "Available", -anchor => 'w'); $hl->headerCreate(2,-itemtype => 'window',-widget => $label3); $label4 = $hl->Label(-text => "co lics.", -anchor => 'w'); $hl->headerCreate(3,-itemtype => 'window',-widget => $label4); $label5 = $hl->Label(-text => "co_lics.%", -anchor => 'w'); $hl->headerCreate(4,-itemtype => 'window',-widget => $label5); $label6 = $hl->Label(-text => "co_lic_user", -anchor => 'w'); $hl->headerCreate(5,-itemtype => 'window',-widget => $label6); $label7 = $hl->Label(-text => "co_user%", -anchor => 'w'); $hl->headerCreate(6,-itemtype => 'window',-widget => $label7); $general = $hl->ItemStyle('text', -selectforeground =>'black', -anchor =>'center'); #my @keys = qw (user1 user2 user3 user4); my @keys = qw (user1 user2 ); my $path = 0; foreach my $key (@keys) { for my $tool (sort keys %{$data->{$key}}) { _insertData($path,$tool,$key); $path++; } } sub _insertData { my $path = shift; my $tool = shift; my $usr = shift; $hl->add($path); $hl->itemCreate($path,0,-text=> $data->{$usr}->{$tool}->{feature},-style => $general); $hl->itemCreate($path,1,-text=> $data->{$usr}->{$tool}->{vendor}, -style => $general); $hl->itemCreate($path,2,-text=> $data->{$usr}->{$tool}->{issued}, -style => $general); $hl->itemCreate($path,3,-text=> $data->{$usr}->{$tool}->{inuse}, -style => $general); $hl->itemCreate($path,4,-text=> "20%", -style => $general); $hl->itemCreate($path,5,-text=> 'N/A', -style => $general); $hl->itemCreate($path,6,-text=> "30%", -style => $general); } MainLoop;