Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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?

jdtoronto

Comment on Perl/Tk HList double click binding issue
Download Code
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
      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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2014-09-21 03:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (166 votes), past polls