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

Below is the relevent snipit of code: I wish to justify text in the columns of my hlist as 'right', 'left' or 'center'. How would I accomplish this?? "justify" does not seem to be a valid method for the hlist or it's items?
my $top = new MainWindow(-title => ("\u$title" . " X") ); my $hlist = $top->Scrolled("HList", -header => 1, -columns => 7, -scrollbars => 'osoe', -width => 50, -selectbackground => 'darkgreen', )->pack(-expand => 1, -fill => 'both'); my $option = 0; foreach (qw(jobID user state queue cpu-time memory jobName)) { $hlist->header('create', $option++, -text => $_); } my $option = 0; $hlist->add($jobID); foreach ($jobID, $user, $state, $queue, $cpu, $mem, $name) { $hlist->itemCreate($jobID, $option++, -text => $_); }

Replies are listed 'Best First'.
Re: PerlTk; text justification in an hlist
by PodMaster (Abbot) on Jan 29, 2004 at 21:06 UTC
    "justify" does not seem to be a valid method for the hlist or it's items?
    That's because it's not a method. The docs say it's an option. See Tk::Ditem for more info.

    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.

      You are correct, I'm looking for an option not a method. However, I still have a problem...I cannot see a "justify" option for hlist. Can you?
        perldoc Tk::HList says
        Each list entry in an HList widget is associated with a display item. The display item determines what visual information should be displayed for this list entry. Please see the Tk::DItem manpage for a list of all display items. When a list entry is created by the itemCreate, add or addchild widget methods, the type of its display item is determined by the -itemtype option passed to these methods. If the -itemtype is omitted, then by default the type specified by this HList widget's -itemtype option is used.
        Now go read the Tk::DItem docs.
        http://perltk.org/ptknews/search.cgi?Search=justify
        Re: How do you justify the contents of an HList column?

        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.