Dear Fellow monks,

I seek your wisdom on a particular issue with the Tk::Columns module. I have a large text file that i need to display in a tabular form and sort. I discovered this Tk::Columns module and I found it to be up to the task. However, I have two basic problems (both of which are closely related ) regarding the configuration of the table . First the code (with some sample data)

#! /usr/bin/perl use Tk; use strict; use warnings; use Tk::Columns; my $l_MainWindow = Tk::MainWindow->new(); $l_MainWindow->geometry("800x500+0+0"); my $l_Columns = $l_MainWindow->Columns ( '-command' => sub {printf ("Selected [%s]\n", join ('|', @_));}, '-image' => $l_MainWindow->Pixmap ('-file' => 'mini-doc.xpm'), '-listforeground' => 'blue4', '-listbackground' => 'beige', '-buttonbackground' => 'brown', '-buttonforeground' => 'white', '-selectmode' => 'extended', '-sort' => 'true', )->pack ( '-expand' => 'true', '-fill' => 'both', ); my @columns_desc = ("Col A", "Col B", "Col C", "Col D", "Col E +" ); $l_Columns->ColumnButton( -text => "$columns_desc[0]", -width => 10 ); $l_Columns->ColumnButton( -text => "$columns_desc[1]", -width => 10 ); $l_Columns->ColumnButton( -text => "$columns_desc[2]", -width => 10 ); $l_Columns->ColumnButton( -text => "$columns_desc[3]", -width => 10 ); + $l_Columns->ColumnButton( -text => "$columns_desc[4]", -width => 10 ); + while (<DATA>) { chomp; $_ =~ s/[\r\n]*$//; $l_Columns->insert ('end', split()); } Tk::MainLoop(); __DATA__ drwxrwxrwx 2 nobody nogroup 512 May 1 19:20 . drwxrwxrwx 5 nobody nogroup 512 Apr 30 01:14 .. -rwxrwxrwx 1 dkw nogroup 3774 Dec 31 1969 camel.ico -rwxrwxrwx 1 dkw nogroup 1888 Apr 29 15:19 camel_s.gif -rwxrwxrwx 1 dkw nogroup 218 Apr 8 12:11 checkbox.pl -rwxrwxrwx 1 dkw nogroup 8272 Apr 8 12:11 client.xpm -rwxrwxrwx 1 dkw nogroup 538 May 1 19:23 columns.pl -rwxrwxrwx 1 dkw nogroup 655 Apr 8 12:11 comboentry.pl -rwxrwxrwx 1 dkw nogroup 2873 Apr 8 12:11 database.xpm -rwxrwxrwx 1 dkw nogroup 3205 Apr 8 12:11 iconcanvas.pl -rwxrwxrwx 1 dkw nogroup 2711 Apr 8 12:11 mail.xpm -rwxr--r-- 1 nobody nogroup 837 May 1 19:00 menustrip.pl -rwxrwxrwx 1 dkw nogroup 8272 Apr 8 12:11 netclient.xpm -rwxrwxrwx 1 dkw nogroup 587 Apr 8 12:11 progressindicato +r.pl -rwxrwxrwx 1 dkw nogroup 7879 Apr 8 12:11 server.xpm -rwxrwxrwx 1 dkw nogroup 982 Apr 8 12:11 splitframe.pl -rwxrwxrwx 1 dkw nogroup 919 Apr 8 12:11 tabbedform.pl -rwxrwxrwx 1 dkw nogroup 2020 Apr 29 12:44 tabframe.pl -rwxrwxrwx 1 dkw nogroup 1239 Apr 8 12:11 tableedit.pl -rwxrwxrwx 1 dkw nogroup 156 Apr 8 12:11 test.dat -rwxrwxrwx 1 dkw nogroup 0 May 1 19:24 testfile.txt

Now, the problems :

1. How do I reconfigure the height of the rows ?. The text file is very large. Since the data is placed close to each other, the data looks crowded and messy. I want to increase the spacing to make it look much cleaner

2. How do i insert a new line character in one of the table entries.? Now, I have multiline entries in some rows e.g : "This is a \n sample \n text" (although I have not included such entries here). The moment it encounters such a value, it seems to trim out the new line characters and proceeds with printing the entry. HOw do i fix this ??

Thank you in advance..!

In reply to Tk::Columns height and new line character by reaper9187

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.