On 2012-07-31, at 3:10 PM, Scott Parrill <[email protected]> wrote:
> I have been trying to get a window that has a frame that is scrolled and a
> frame that is not scrolled.  Using the very helpful post archived at
> http://www.nntp.perl.org/group/perl.tcltk/2010/03/msg393.html, I think I
> have gotten very close to what I want.  The problem I still have is that
> the widgets in the frame with the scrollbar do not move when I move the
> scrollbar.  I'm certain I'm missing something simple but I don't see what.
> 
> If anyone can suggest what silly little piece I have missed, I would be
> grateful.  Here is the code I am using:
> 
> use Tkx;
> Tkx::package_require("BWidget");
> 
> $rows = 10;
> $columns = 20;
> 
> $mw = Tkx::widget->new(".");
> $mw->g_grid_columnconfigure(0, -weight => 1);
> $mw->g_grid_rowconfigure(0, -weight => 1);
> 
>  $mwf1 = $mw->new_ttk__frame();
>  $mwf1->g_grid(-column => 0, -row => 0, -sticky => 'ew');
>  $mwf1->g_grid_columnconfigure(0, -weight => 1);
>  $mwf1->g_grid_rowconfigure(0, -weight => 1);
>    $button = $mwf1->new_ttk__button(-text => 'button');
>    $button->g_grid(-column => 0, -row => 0);
> 
>  $mwf2 = $mw->new_ttk__frame();
>  $mwf2->g_grid(-column => 0, -row => 1, -sticky => 'ew');
>  $mwf2->g_grid_columnconfigure(0, -weight => 1);
>  $mwf2->g_grid_rowconfigure(0, -weight => 1);
> 
>    $mwsw = $mwf2->new_ScrolledWindow(-managed => 0);
>      $mwswf1 = $mwsw->new_ScrollableFrame();
>    $mwsw->setwidget($mwswf1);
>    $mwsw->g_grid(-column => 0, -row => 0, -sticky => 'ew');

I believe this g_grid call here isn't what you want.  The setwidget call above 
will place the widget in the parent with the correct parameters.

>    $mwsw->g_grid_columnconfigure($mwswf1, -weight => 1);
>    $mwsw->g_grid_rowconfigure($mwswf1, -weight => 1);
> 
>  $f = Tkx::widget->new($mwswf1->getframe());
>  $f->g_grid(-column => 0, -row => 0, -sticky => 'ew');
> 
> for $i (0 .. ($rows - 1)) {
>  for $j (0 .. ($columns - 1)) {
>    $cell[$i][$j] = $f->new_ttk__entry(-width => 10);
>    $cell[$i][$j]->g_grid(-column => $j, -row => $i, -padx => 0, -pady =>
> 0, -sticky => 'nsew');
>    $cell[$i][$j]->insert(0, "$i, $j");
>  }
> }
> 
> 
> Tkx::update('idletasks');
> Tkx::wm_geometry($mw, "600x" . Tkx::winfo_reqheight($mw));
> 
> Thanks,
> Scott

Reply via email to