blackadder has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks

I have three data categories; Business Units, Groups and Functions. Each Business Unit has a number of Groups, and each Group has a number of Functions. This data is stored in a query called Hydra-data in MS Access database (sorry).

Here is an n Example of this data:

IT,Development,GUI
IT,Operations,Trading,BackOffice
IT,Eng,SAN
FID,FuturesMarket
FID,Trading,Secretaries
IED,Quants
IED,CashSales,USSales
IED,FarEast,Japan
IED,SaleDesk1,CashSales,PrimSales
IED,SaleDesk2,CashSales,UKSales
IPB,ClientSevices,International


So I started by looking at this bit of code
# c:/pel/bin use strict; use Tk (); use Tk::TList; my $mw = Tk::MainWindow->new(); my $image = $mw->Getimage('folder'); my $tlist = $mw->TList(-orient => 'vertical'); for my $text ( qw/IBD IED IPB IT IFO IIM ER LEGAL FID TRESUERY CORPSER +V CORPSEC/ ) { $tlist->insert('end', -itemtype=>'imagetext', -image=>$image, -text=>$text); } $tlist->pack(-expand=>'yes', -fill=>'both'); Tk::MainLoop;
But this code doesn’t serve my need, because TK::TList is pointing at /IBD IED IPB IT IFO IIM ER LEGAL FID TRESUERY CORPSERV CORPSEC/

Is there away where I can get Tk to represent this data in a directory like hierarchy structure, similar to Tk::DirTree. So I can have a display of folders representing the Business Units, then inside those folders another folders for Groups and then for functions?

Also, if I read the above data into a hash then can I use TList to do the job?

Thanks for your help
Blackadder

Replies are listed 'Best First'.
Re: Represnting a query data in a Tk::DirTree like manner
by PodMaster (Abbot) on Sep 12, 2004 at 17:59 UTC
    Is there away where I can get Tk to represent this data in a directory like hierarchy structure, similar to Tk::DirTree. So I can have a display of folders representing the Business Units, then inside those folders another folders for Groups and then for functions?
    Yes, just do what Tk::DirTree does (Tk::DirTree is pure perl, so Use The Source Luke).
    Also, if I read the above data into a hash then can I use TList to do the job?
    Sure, why not.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      How please.

      Thanks
      Blackadder
Re: Represnting a query data in a Tk::DirTree like manner
by gri6507 (Deacon) on Sep 13, 2004 at 12:42 UTC
    You could also use Tk::HList if you want to have a hierarchal structure but not display the folder icons next to each branch. I found this very useful in my application since the notion of "folders" was inappropriate, yet I still wanted the h-structure.
      So, I can have a Hlist and hierarchal structre but I can't have an icon of a folder next to each branch!,.....

      Never mind,....I will use the table like notion.

      Thanks for your help friend.

      Regards
      Blackadder
        Then try Tk::Tree which is a Tk::HList with some magic to display the folder icons.