Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Perl Tk : show list box items in grid style

by selva (Scribe)
on May 19, 2010 at 08:34 UTC ( #840636=perlquestion: print w/ replies, xml ) Need Help??
selva has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
I have a script which will get data from mysql and populate it in to listbox. Data has more than 40 rows and 20 columns. Currently i used "|" delimiter to separate the column. For separating rows i don't know the way. I want to display the data like excel format.

If anyone could point me in the right direction, it would be much appreciated.

Comment on Perl Tk : show list box items in grid style
Re: Perl Tk : show list box items in grid style
by lamprecht (Friar) on May 19, 2010 at 09:38 UTC
Re: Perl Tk : show list box items in grid style
by biohisham (Priest) on May 19, 2010 at 09:45 UTC
    Since you are using Tk then you have either Tk::GridColumns or Tk::Table, the later is scrollable and provides a nice layout.....



    Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.

      In Tk::Table and Tk::TableMatrix there is no click event. My Requirement is If i click any row it should affect other list box.

      I tried with Tk::MListbox module. But here height option is not working.

        In Tk::Table and Tk::TableMatrix there is no click event.

        Example of Tk::TableMatrix in "list mode". The user can click a row and the program responds with a message in the console."

        use strict; use warnings; use Tk; use Tk::TableMatrix; my $main = MainWindow->new; $main->title("TM - in list mode"); my $xtvar; foreach my $row (0 .. 7){ foreach my $col (0 .. 2){ if ($col == 0) { $xtvar->{"$row,$col"} = "click row $row"; } else { $xtvar->{"$row,$col"} = "r$row, c$col"; } } } my $xtable = $main->Scrolled( 'TableMatrix', -rows => 8, -cols => 3, -ipadx => 3, -variable => $xtvar, -selectmode => 'single', -selecttype => 'row', -resizeborders => 'none', -state => 'disabled', -cursor => 'top_left_arrow', -bg => 'white', -scrollbars => 'ose', )->pack; # Clean up if mouse leaves the widget $xtable->bind( '<FocusOut>', sub { my $w = shift; $w->selectionClear('all'); } ); # Highlight the cell under the mouse $xtable->bind( '<Motion>', sub { my $w = shift; my $Ev = $w->XEvent; if ( $w->selectionIncludes( '@' . $Ev->x . "," . $Ev->y ) ) { Tk->break; } $w->selectionClear('all'); $w->selectionSet( '@' . $Ev->x . "," . $Ev->y ); Tk->break; } ); # MouseButton 1 event $xtable->bind( '<1>', sub { my $w = shift; $w->focus; my ($rc) = @{ $w->curselection }; # Do something with the selection print " Selection: $rc\n"; } ); MainLoop;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://840636]
Approved by biohisham
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2014-12-21 03:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (102 votes), past polls