in reply to Re^2: how to set tab order in the perl tk?
in thread how to set tab order in the perl tk?

I said earlier manual scrollbars are a PITA, :-( The Scrolled Pane works pretty well, maybe instead of making your own scrollbars, get them from a Scrolled Pane. Try making a Scrolled('Pane'), then extract the scrollbars with $yscrollbar = $spane->Subwidget('yscrollbar'); and same for x.

If that dosn't work, post a complete minimal code example of what you are trying, and maybe someone will spot a way to make it work.


I'm not really a human, but I play one on earth Remember How Lucky You Are
  • Comment on Re^3: how to set tab order in the perl tk?

Replies are listed 'Best First'.
Re^4: how to set tab order in the perl tk?
by kapsule (Acolyte) on Dec 24, 2008 at 04:05 UTC
    Thanks Zentara!!! I have tried the above approach, but not working. try the code below.
    use strict; use warnings; use Tk; use Tk::Table; use Tk::Pane; use constant COLUMNS => 5; my $mw = MainWindow->new(); $mw -> resizable (0,0); $mw -> geometry ("+10+10"); $mw -> geometry ("750x500"); my $spane = $mw->Scrolled('Pane', -scrollbars => 'oe', -bg => "orange" )->pack(-expand => 1, -fill => 'both'); #my $yscrollbar = $spane->Subwidget('yscrollbar'); #$yscrollbar->focus; my $local_title = $mw->title ("perl: New File"); my $basic_label = $spane->Label ( -text => "Old Names", -font => "verdanafont 10 bold", -relief => "groove" ) -> pack ( -side => "top", -anchor => "nw", -pady => "10", -padx => "5", -ipadx => "5" ); my $table_frame = $spane->Frame ()->pack (-side => "top", -padx => "10 +"); our $table = $table_frame->Table ( -columns => COLUMNS, -rows => 10, -scrollbars => "o", -fixedrows => 1, -fixedcolumns => 1, -relief => 'raised', -pady => "20", -takefocus => "0" ); for my $col_index (1 .. COLUMNS - 1) { my $col_label = $table->Label ( -text => "$col_index", -width => 20, -relief =>'ridge' ); $table->put (0, $col_index, $col_label); } our $table_frame_two = $spane->Frame (); our $table_two = $table_frame_two ->Table ( -columns => COLUMNS, -rows => 10, -scrollbars => "o", -fixedrows => 1, -fixedcolumns => 1, -relief => 'raised', -takefocus => "0", -pady => "5" ); for my $col_index_2 (1 .. COLUMNS - 1) { my $col_label_2 = $table_two->Label(-text => "$col_index_2 ", -wid +th => 20, -relief =>'ridge'); $table_two->put(0, $col_index_2, $col_label_2); } my $button_frame = $spane->Frame (-bg => "red")->pack ( -side => "bottom", -fill => "both", -anchor => "sw", -pady => "10", -padx => "20" ); our $adv_button = $spane->Button ( -text => "New Names", -font => "verdanafont 10 bold", -command => sub { if ($table_frame_two ->ismapped) { $table_frame_two -> packForget(); } else { $table_frame_two -> pack(); } } )->pack ( -side => "top", -anchor => "w", -pady => "15", -padx => "5" ); our $enter_button = $button_frame -> Button ( -text => "Enter", -font => "verdanafont 10 bold" )->pack ( -side => "left", -padx => "5", -ipadx => "5" ); our $exit_button = $button_frame -> Button(-text=>"Exit", -font => "verdanafont 10 bold") -> pack(-side=>"right",-padx=>"5", -ipadx=>"5"); for my $col_entry (1 .. COLUMNS - 1) { for my $row_entry (1 .. 10 - 1) { my $ent = $table->Entry ( -font => "verdana 10", )-> pack ( -ipady => "15"); $table->put ($row_entry,$col_entry,$ent); } } $table->pack (); for my $col_entry_2 (1 .. COLUMNS - 1) { for my $row_entry_2 (1 .. 10 - 1) { my $ent_2 = $table_two->Entry ( -font => "verdana 10", )-> pack ( -ipady => "15"); $table_two->put ($row_entry_2,$col_entry_2,$ent_2); } } $table_two->pack (); MainLoop();
    thanks in advance..
      To be honest, I can't figure out what you are trying to do? What is it supposed to do? I can't decipher your table1 and table2 logic with packforget. Make a simpler example, and state exactly what you expect it to do.

      At a quick glance, if you comment out your $mw size restrictions, the scrollbars work.

      #$mw -> resizable (0,0); #$mw -> geometry ("+10+10"); #$mw -> geometry ("750x500");
      this indicates you have a packing problem.

      I'm not really a human, but I play one on earth Remember How Lucky You Are
        Actually, packforget is used to make that table invisible, when that button is pressed again. It means at the first press of button table will appear and in the next press of button table will disappear. Well I cannot comment out my size restrictions, because the moment i do that whole window become so small (of course with scroll), but it does not serve my purpose. I want my first table and following buttons to be shown by default, and when "new names" button is pressed a table should appear with a scrollbar (in main window) having default focus. I think this will make the things clearer.