Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Looking for a standalone separator for Perl/Tk

by kbrannen (Beadle)
on Mar 24, 2017 at 18:59 UTC ( [id://1185820]=note: print w/replies, xml ) Need Help??


in reply to Re: Looking for a standalone separator for Perl/Tk
in thread Looking for a standalone separator for Perl/Tk

Thanks! It's good to know I was on a reasonable path.

I just wished there was something simpler like:
use Tk::Separator; $mw->Separator(-orient => 'horizonal')->pack(); # -or- $mw->Separator(-orient => 'vertical')->pack();
and all of the little details would automatically be taken care of. :) I suppose I could look at writing such a thing. Hmm, maybe I could steal some code from the Menubar or PanedWindow widgets since they have something like that already and make it its own widget.

Replies are listed 'Best First'.
Re^3: Looking for a standalone separator for Perl/Tk
by tybalt89 (Monsignor) on Mar 24, 2017 at 19:57 UTC

    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;
      I'd created a make_separator() to help myself, but I like what you've done better. It feels more Perl/Tk'ish. :) Thanks for the help and the lesson!

      Maybe that will help others who search for this.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1185820]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-19 21:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found