Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Perl/Tk HList double click binding issue

by jdtoronto (Prior)
on Oct 11, 2007 at 18:07 UTC ( #644299=perlquestion: print w/replies, xml ) Need Help??
jdtoronto has asked for the wisdom of the Perl Monks concerning the following question:

Esteemed Monks,

I am using Perl/Tk and Tk::DBI::Table which as a Tk::HList as part of it. I would like to have an action performed when I double click on an entry in the list, my code looks like this:

# Using the supplied SQL display a table view of the data. sub doDBItable { my ( $dbh, $SQL, $title ) = @_; debug("+doDBItable"); debug("SQL : $SQL"); if ( not defined $title ) { $title = "List Preview" } my $top = MainWindow->new( -title => $title ); $top->geometry("600x400+50+50"); my $tkdbi = $top->DBITable( -sql => $SQL, -dbh => $dbh, -display_id => 1, -debug => 0, )->pack( -expand => 1, -fill => 'both' ); $tkdbi->Subwidget('table')->configure( -selectmode => 'single', -command => \&procSelected, -browsecmd => sub{ printf "This is id: %s\n", $_[0] }, ); debug("-doDBItable"); return $top; } sub procSelected { printf "Process record %s\n", $_[0]; }
When I click on a row the '-browsecmd' code executes, but the '-command' callback only gets called when I select the row then hit enter. According to the Tk::HList docs, and everything I can find written about the HList widget, it should respond to the double-click also.

Any suggestions?


Replies are listed 'Best First'.
Re: Perl/Tk HList double click binding issue
by jdtoronto (Prior) on Oct 15, 2007 at 19:22 UTC
    Oh dear, where have all the gurus gone? jdtoronto

      I'm sorry for the long delay in responding.
      This may help point you in the right direction. I looked into this issue and came up with the following.

    • When I used your code without alteration I could maximize the window, and the Double-Click would work every once in awhile.
    • There seems to be something slightly off when the header is present on in the table. Possibly a width, or height addition to the existing coordinates.

      So, I used the following code for my table declaration
      $tkdbi->Subwidget('table')->configure( -header => 0, -selectmode => 'single', -command => \&procSelected, -browsecmd => sub{ print "Selected: $_[0]\n" }, );

    • The Double-Click function works great, however the header is no longer there, which means that there is no method for sorting.
    • One thing to consider is that you could create other buttons for the field names drawn from the database. Once the user presses the buttons, you can use perl to sort your stored values.

      I do hope this helps!

      Sincerely, Devin

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://644299]
Approved by Corion
Front-paged by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2017-02-23 13:23 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (347 votes). Check out past polls.