Out of half curiosity, half boredom, and half fun, I tried to build a (very incomplete) vertical entry from a Label widget using newlines to get a vertical display.

#!/usr/bin/perl use strict; use warnings; use Tk; my $text = 'Vertical'; my $entry = 'Entry'; my $mw = MainWindow->new; $mw->geometry( '+600+200' ); $mw->Label(-text => "Two\nVerticalEntry\nWidgets", -fg => 'blue', -font => 'courierbold 20',)->pack; my $middle = $mw->Frame->pack; verticalentry( $middle, \$text, 12, sub {print "left text: $text\n"}, -side => 'left' ); my $updateright = verticalentry( $middle, \$entry, 12, sub {print "right text: $entry\n"}, -side => 'right' ); $middle->Frame(-width => 30)->pack; $mw->Button(-text => 'Exit', -command => sub {$mw->destroy}, )->pack( -side => 'bottom', -fill => 'x' ); $mw->Button(-text => 'Clear Right', -command => sub {$updateright->('' +)}, )->pack( -side => 'bottom', -fill => 'x' ); $mw->repeat( 400, sub { -M $0 < 0 and $mw->destroy } ); # file saved a +fter run MainLoop; -M $0 < 0 and exec $0; # restart on editor save :) sub verticalentry { my ($parent, $textref, $length, $command, @packargs) = @_; my $edit = $parent->Label(-width => 1, -relief => 'sunken', -borderwidth => 3, -font => 'courierbold 30')->pack( @packargs ); my $update = sub { @_ and $$textref = shift; $edit->configure(-text => join "\n", split //, substr $$textref . ' ' x $length, 0, $length); }; $update->(); $edit->bind('<Enter>' => sub { $edit->focus } ); $edit->bind('<Key>' => sub { my $key = $_[0]->XEvent->A; use Data::Dump 'dd'; dd $key; if( $key =~ /^[ -~]$/ ) { length $$textref < $length and $$textref .= $key; } elsif( $key eq "\b" ) { chop $$textref; } elsif( $key eq "\r" ) { $command->(); } $update->(); } ); return $update; }

If nothing else, it shows a way to get a vertical column of text :)

This example has two independent vertical entries just so I could be sure all the closure stuff worked correctly.


In reply to Re: how to write a vertical TK Entry? by tybalt89
in thread how to write a vertical TK Entry? by jsteng

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.