Thank you for providing runnable code! But I am still not sure exactly what you are trying to achieve?
I think you "short-sell" pack(). This the most commonly used geometry manager. The more complex ones like grid() are less commonly used. I have never used Canvas.
When using pack(), you need to think about packing Frames within Frames. Think of a Frame as a widget unto itself. The most common mistake when using pack() is to not use enough Frames.
In the below code, I did have trouble getting the required minimum amount of "blank violet colored space" on the screen. But I haven't coded an Tk in a long time. The main idea with pack, is that if you want your list box to have some indentation from the left, or perhaps to center it on the screen, make a Frame which contains a "dummy" spacer frame, then your Listbox and pack appropriately (often when using enough frames, the default pack will be fine).
When using pack() with some complicated GUI object that needs multiple widgets to "line up" in a vertical sense, get that working say in simple main window Frame on the left hand side of the screen. Then instead of using the mainWindow, put that stuff into a separate Frame and pack that Frame probably within a Frame within the mainWindow.
#!/usr/bin/perl use strict; use Tk; my $mw = MainWindow->new; #$mw->geometry('400x250'); #some issues with this... #see my post my $FirstFrame = $mw->Frame( -bg => 'lavender', -relief => 'sunken', -width => 400, -height => 250)->pack(-expand => 1, -fill => 'both'); my $spacer_frame = $FirstFrame->Frame( -width =>10, # ADJUST THIS TO SEE WHAT IT DOES )->pack(-side => 'left'); my $listbox = $FirstFrame->Scrolled ('Listbox', -bg => 'white', -scrollbars => "e", -selectmode => 'extended', -width => 10, -height => 5, )->pack(-side=>'left'); my @strings2 = qw/apples bananas pears grapes/ x 5; $listbox->insert('end',@strings2); MainLoop();
In reply to Re^3: TK Placing Widgets in a Scrolling Pane
by Marshall
in thread TK Placing Widgets in a Scrolling Pane
by saiftynet
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |