Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: how to write a vertical TK Entry?

by kcott (Archbishop)
on Mar 05, 2020 at 08:43 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2024-04-19 08:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found