Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: how to write a vertical TK Entry?

by kcott (Bishop)
on Mar 05, 2020 at 08:43 UTC ( #11113827=note: print w/replies, xml ) Need Help??

in reply to how to write a vertical TK Entry?

G'day jsteng,

To the best of my knowledge, you cannot do this with Tk::Entry; however, you can code this functionality with Tk::Text.

The following code is fully functional. It shows how to set up the pseudo-entry widget (note the initial text has no spaces; just 12345). The "Latest Entry" button will retrieve the full, possibly edited, text (note the chomp) and update the display above.

#!/usr/bin/env perl use strict; use warnings; use Tk; my $mw = MainWindow::->new(-title => 'Vertical Entry'); $mw->geometry('300x400+40+40'); my $string = '12345'; my $entry = $mw->Text(-width => 1, -wrap => 'char'); $entry->pack(-fill => 'y', -side => 'left'); $entry->insert('1.0', $string); $mw->Label(-textvariable => \$string) ->pack(-fill => 'x', -side => 'top'); $mw->Button(-text => 'Latest Entry', -command => sub { chomp($string = $entry->get('1.0', 'end')) }) ->pack(-fill => 'x', -side => 'top'); $mw->Button(-text => 'Exit', -command => sub { exit }) ->pack(-side => 'bottom'); MainLoop;

It looks pretty weird to me, but that's what you asked for. :-)

— Ken

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2021-01-24 00:22 GMT
Find Nodes?
    Voting Booth?