Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to stack 2 buttons and attach a 3rd full height ?

1 view
Skip to first unread message

$Bill

unread,
Sep 7, 2021, 10:11:02 PM9/7/21
to
(no activity in Tk groups so trying here)

I have 3 buttons - let's call them Abcd, Efgh and STOP (that's the text in them) that I want
to stack prior to a LabelFrame.

I want the buttons to look like in the test code example below.

Please feel free to modify the code in frames $f4/5 to get the proper packing shown below.
I've tried hundreds of combinations with no luck.

########################## Test Code #####################################################
#!perl --

use strict; use warnings; no warnings qw(once);

require Tk;
require Tk::widgets;
import Tk::widgets qw(Button Entry Frame Label Labelframe ROText Scrollbar);

my $ffam = 'Fixedsys';
my $fwt = 'Medium'; my $fsl = 'R'; my $fwd = 'Normal'; my $fpx = '120';
my $font = "-*-$ffam-$fwt-$fsl-$fwd-*-*-$fpx-*-*-*-*-*-*";
my $windowWidth = 80;

my $mw = new MainWindow (-title => "Test GUI ($$)");
# stripped f1 and f2 out
my $f3 = $mw->Frame->pack(-anchor => 'w', -fill => 'both', -expand => 1);
my $t31 = $f3->ROText(-font => $font, -width => 8, -height => 1,
-relief => 'flat')->pack(-side => 'left');
$t31->Contents('T31=');
my $i31 = $f3->Entry(-font => $font, -width => 12, -validate => 'none',
)->pack(-side => 'left', -fill => 'both', -expand => 1);
my $t32 = $f3->ROText(-font => $font, -width => 4, -height => 1,
-relief => 'flat')->pack(-side => 'left');
$t32->Contents('T32');
my $i32 = $f3->Entry(-font => $font, -width => 32, -validate => 'none',
)->pack(-side => 'left', -fill => 'both', -expand => 1);
my $t33 = $f3->ROText(-font => $font, -width => 7, -height => 1,
-relief => 'flat')->pack(-side => 'left');
$t33->Contents('T33');
my $i33 = $f3->Entry(-font => $font, -width => 24, -validate => 'none',
)->pack(-side => 'left', -fill => 'both', -expand => 1);

my $f4 = $mw->Frame->pack(-anchor => 'w', -fill => 'both', -expand => 1);

our $b41; # temp
our $b42;
our $b43;
our $lf1;

# right now I can get it to this:
#|----| |----| |
#|Abcd| | |--Title-------------------------------------------------------|
#|----|----|STOP| Label Frame (x scrolled Listbox - 1 line) |
#| |Efgh| |<------scroll bar-------------------------------------------->|
#| |----|----| |

# But I want this:
#|----|----| |
#|Abcd| |--Title------------------------------------------------------------|
#|----|STOP| Label Frame (x scrolled Listbox - 1 line) |
#|Efgh| |<------scroll bar------------------------------------------------->|
#|----|----| |

# STOP should be centered in double high button and be to the right of the 2
# smaller one line buttons on left (Abcd & Efgh) which I can't get to stack.

#----- Stuff that needs proper packing below with latest failing attempt -------


$b41 = $f4->Button(-text => 'Abcd', -font => $font,
-foreground => 'red', -command => sub { ; }
)->pack(-side => 'left', -anchor => 'nw', -fill => 'none', -expand => 0, );

$b42 = $f4->Button(-text => 'Efgh', -font => $font,
-foreground => 'black', -command => sub { ; }
)->pack(-side => 'left', -anchor => 'sw', -fill => 'none', -expand => 0, );

$b43 = $f4->Button(-text => 'STOP', -font => $font,
-foreground => 'black', -command => sub { ; },
)->pack(-side => 'left', -after => $b42, -fill => 'y', -expand => 0);


#----- End Stuff that needs proper packing but below might need changes to $lf1
#----- packing due to any changes above --------------------------------------

#--------- Progress Frame Listbox w/Scrollbars -------------------------------
$lf1 = $f4->Labelframe(-text => 'Progress', -font => $font,
-relief => 'ridge')->pack(-fill => 'both', -expand => 1);



#----------------Below should not need any help ------------------------------
my $lb1 = $lf1->Scrolled('Listbox', -scrollbars => 's',
-font => $font, -relief => 'sunken', -width => $windowWidth, -height => 1,
)->pack(-side => 'bottom', -fill => 'both', -expand => 1);

my $lf2 = $mw->Labelframe(-text => 'Log', -font => $font,
-relief => 'ridge')->pack(-fill => 'both', -expand => 1);

my $lb2 = $lf2->Scrolled('Listbox', -scrollbars => 'ose',
-font => $font, -relief => 'sunken', -width => $windowWidth, -height => 12,
-setgrid => 1, -selectmode => 'extended',
)->pack(-side => 'bottom', -fill => 'both', -expand => 1);

# ignore the why for this mainloop code
our $InTk = 0;
our $ML = '
$InTk = 1;
unless ($Tk::inMainLoop) {
$Tk::inMainLoop = 1;
while (Tk::MainWindow->Count) {
Tk::DoOneEvent (0);
}
$Tk::inMainLoop = 0;
}
$InTk = 0;
';
eval $ML;

__END__

######################################################################################

$Bill

unread,
Sep 8, 2021, 5:36:31 AM9/8/21
to
Never mind, I figured it out. I didn't know you could mix pack & grid methods.

George Bouras

unread,
Sep 8, 2021, 2:27:17 PM9/8/21
to
Στις 8/9/2021 12:36 μ.μ., ο/η $Bill έγραψε:
> Never mind, I figured it out.  I didn't know you could mix pack & grid
> methods.

phewww
0 new messages