Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Perl Tk : show list box items in grid style

by selva (Scribe)
on May 19, 2010 at 13:51 UTC ( #840707=note: print w/ replies, xml ) Need Help??


in reply to Re: Perl Tk : show list box items in grid style
in thread Perl Tk : show list box items in grid style

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.


Comment on Re^2: Perl Tk : show list box items in grid style
Re^3: Perl Tk : show list box items in grid style
by stefbv (Chaplain) on May 19, 2010 at 17:09 UTC
    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;

      Hello stefbv,

      Sorry to ask the following two questions on your four year old response. But from your home page on this site I realize that you were on this site about 3 hours ago. So here are the questions,

      1. Where do I find what are all the fields that a Perl/Tk programmer can access from an XEvent object and what do they stand for? (Mastering Perl/Tk book by Oreilly Press doesn't give any details except Chapter 15 merely makes a mention of it when accessing 'K' and 'N' for keysym text and decimal). Also the Widget.pm has following

      sub XEvent { shift->{'_XEvent_'} }
      but I'm unable to go any further than this to access the pure tcl/tk code to understand the same.


      2. In the selectionSet and selectionIncludes method you used the value:
      '@' . $Ev->x . "," . $Ev->y
      what does this @ and the full expression stand for. The perldoc for TableMatrix (and other widgets like TList decendants) has no such documention but your program works a like a charm


      As I'm still trying to learn Perl and Perl/Tk I had to spend few hours trying to look around but to no avail. Therefore any information would be very useful. Many Thanks

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2014-09-15 04:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (145 votes), past polls