Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

    These are short questions and I hope, are simple ones

  1. In the following code, I attempt to activate the topmost cell on the left so that the arrow keys (Left, Right, Up and Down) can be used for right away browsing the cells in TableMatrix without prior having to select the cell by the mouse button click. But neither of the methods: ( activate , selectionSet ) work.

  2. Calling the methods do however, highlight the cell. The activate method causes the cell to get highlighted with grey color but the selectionSetmethod with blue color. Don't know why is the difference in color.

  3. As an aside, I'll squeeze in one more question. I've seen zentara (no longer active on this site) in Re: Increase The coloumn size in Perl Tk? using negative column indexes while setting column width.
    $t->colWidth( -2 => 8, -1 => 9, 0=> 12, 4=> 14);
         As per documentation, the value specified for setting the width can be negative (for pixels instead of positive for characters). But what do the negative value for column index refer to ?

Thanks in advance.

use strict; use warnings; use Tk; use Tk::TableMatrix; my $mw = MainWindow->new; my $tm = $mw->Scrolled('TableMatrix', -rows => 5, -cols => 10, -width => 5, -height => 12, -selecttitles => 0, -bg=>'yellow', -drawmode => 'slow', )->pack(-expand => 1, -fill => 'both'); $tm->activate("topleft"); #$tm->selectionSet("2,3"); MainLoop;

Replies are listed 'Best First'.
Re: activate and selectionSet methods, negative columns in TableMatrix (focus)
by Anonymous Monk on Jan 22, 2015 at 07:29 UTC
      Hi There,

          Thank you for the swift response.
      1. Yes. $tm->focus; does it make it work and thank you for that. Now I realize that $tm->activate("topleft"); doesn't implicitly call $tm->focus;. That said,
        $tm->focus; $tm->activate("topleft");
        has the same effect as,
        $tm->activate("topleft"); $tm->focus;
        I'm not sure why this is so.

      2. Any answers to second question?

      3. I'm a entry level learner. So I don't understand the Perl source code well. That aside, while answer the sounds reasonable that -ve column numbers refer to those from counted from the right(starting rightmost column at -1 as there is no -0), I tried
        $tm->colWidth (0, 25); print $tm->colWidth(), "\n";

        prints,
        0 25

        $tm->colWidth (-10, 32); $,="|"; print $tm->colWidth(), "\n";

        prints,
        0 25|-10 32|
      4. Now -10 refers to first column. The following callback for -browsecommand option,
        sub validate_browse { $tm->colWidth (-10, 32); $tm->configure(-padx =>($tm->cget(-padx))); #display refresh trick, }
        doesn't change the width of first column. Why is this so?

        Many thanks in advance.

        Any answers to second question?

        Yes, figure it out :)Tk::WidgetDump can help you get more diagnotical with most widgets

        I'm a entry level learner...Why is this so?

        :) Second verse same as the fist :) you're going to have to write a little code to figure it out, and maybe read a bit of code -- a good 15-60 minutes of work ... maybe

        Oooh, another hint, the "original" tablematrix documentation might answer stuff (might not too) http://tktable.sourceforge.net/tktable/doc/tkTable.html

        I'm just not in the mood for a tk info hunt ATM , sorry :)

Re: activate and selectionSet methods, negative columns in TableMatrix
by RonW (Parson) on Jan 22, 2015 at 21:07 UTC

    Side note: Last I heard from zentara, he said something about being deep fried.