in reply to Re^2: Looking for a standalone separator for Perl/Tk
in thread Looking for a standalone separator for Perl/Tk
Like this ?
#!/usr/bin/perl # http://perlmonks.org/?node_id=1185809 use strict; use warnings; use Tk; sub Tk::Separator { my ($self, %rest ) = @_; my $direction = delete $rest{'-orient'} // 'horizontal'; $self->Frame( %{ {%rest, -bg => 'black', $direction eq 'vertical' ? '-width' : '-height' => 2 } } ); } my $mw = MainWindow->new; $mw->Label( -text => 'top part', -height => 5, )->pack; $mw->Separator()->pack( -fill => 'x' ); $mw->Label( -text => 'bottom part', -height => 5, )->pack( -side => 'bottom'); $mw->Separator()->pack( -side => 'bottom', -fill => 'x' ); $mw->Label( -text => 'left part', -height => 5, -padx => 25, )->pack( -side => 'left'); $mw->Separator( -orient => 'vertical')->pack( -side => 'left', -fill = +> 'y' ); $mw->Label( -text => 'middle part', -height => 5, -padx => 25, )->pack( -side => 'left'); $mw->Separator( -orient => 'vertical')->pack( -side => 'left', -fill = +> 'y' ); $mw->Label( -text => 'right part', -height => 5, -padx => 25, )->pack( -side => 'left'); MainLoop;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Looking for a standalone separator for Perl/Tk
by kbrannen (Beadle) on Mar 24, 2017 at 22:56 UTC |