G'day Marshall,
You asked me two questions about your code (via /msg). Generally, I'd recommend you actually post these questions; that way, if I'm unavailable, someone else could answer them. I'll answer the second question first: it applies to the answer to the first question.
"With the geometry statement, I couldn't get the listbox to appear at top of the main frame"
That has nothing to do with geometry(). If you manually resize the GUI, you'll see the Listbox in the centre of the left-hand side. Look for -side and -anchor in Tk::pack. The former defaults to top, you've changed it to left, that's where it appears, all good so far. The latter defaults to center, you haven't changed that, so it appears in the centre, not what you want; had you changed that to n, it would appear at the top (which is where you want it).
"Maybe you can show me how to make my code work as OP intended"
Here's a brief list of changes I made to your code:
Here's the modified code:
#!/usr/bin/env perl use strict; use warnings; use Tk; my $mw = MainWindow->new; $mw->geometry('400x250'); my $FirstFrame = $mw->Frame( -bg => 'lavender', -relief => 'sunken', )->pack(-expand => 1, -fill => 'both'); my $listbox = $FirstFrame->Scrolled('Listbox', -bg => 'white', -scrollbars => "e", -selectmode => 'extended', -width => 200/7, -height => 212/15, )->pack(qw{-side left -anchor n -padx 50 -pady 12}); my @strings2 = qw/apples bananas pears grapes/ x 5; $listbox->insert('end',@strings2); MainLoop();
This code now renders exactly the same as the OP's original code.
There is only one difference in functionality that I detected. If you manually resize the GUI, with this code, the Listbox will also resize; with the OP's code, the Listbox will be chopped off on the right, at the bottom, or possibly on both of those sides. In either case, I can still scroll the list with the mousewheel. So that's a serendipitous improvement.
— Ken
In reply to Re^4: TK Placing Widgets in a Scrolling Pane
by kcott
in thread TK Placing Widgets in a Scrolling Pane
by saiftynet
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |