#!/usr/bin/env perl use strict; use warnings; use Tk; my $mw = MainWindow::->new(-title => "Ken's Guess"); my %frame_pack_opts = qw{-fill x -padx 10 -pady 10}; my $app_preamble_F = $mw->Frame()->pack(%frame_pack_opts); my $letter_buttons_F = $mw->Frame()->pack(%frame_pack_opts); my $copy_from_F = $mw->Frame()->pack(%frame_pack_opts); my $paste_to_F = $mw->Frame()->pack(%frame_pack_opts); my $exit_F = $mw->Frame()->pack(%frame_pack_opts); chomp(my $app_preamble = <<'EOT'); The "Copy from:" entry can only be modified with the "Select:" buttons. Any text here may be selected and copied. The "Paste to:" entry can be modified in any way you want. It's primary function was to test that text copied from the "Copy from:" entry could be pasted; however, you can also type text from the keyboard, select existing text, and delete text. EOT $app_preamble_F->Label(-text => $app_preamble, -justify => 'left' )->pack(-side => 'left'); my $copy_from_entry; my $copy_from_value = ''; $letter_buttons_F->Label(-text => 'Select: ')->pack(-side => 'left'); for my $letter ('A' .. 'G') { $letter_buttons_F->Button(-text => $letter, -command => sub { $copy_from_entry->configure(-state => 'normal'); $copy_from_value = $letter; $copy_from_entry->configure(-state => 'readonly'); } )->pack(-side => 'left'); } $copy_from_F->Label(-text => 'Copy from: ')->pack(-side => 'left'); $copy_from_entry = $copy_from_F->Entry( -textvariable => \$copy_from_value, -state => 'readonly' )->pack(-side => 'left'); chomp(my $paste_to_preamble = <<'EOT'); I have to assume that the widget, where you want to paste this text, is part of another application. Otherwise, this makes no sense at all. EOT $paste_to_F->Label(-text => $paste_to_preamble, -justify => 'left' )->pack(-anchor => 'w', -pady => 5); $paste_to_F->Label(-text => 'Paste to: ')->pack(-side => 'left'); $paste_to_F->Entry()->pack(-side => 'left'); $exit_F->Button(-text => 'Exit', -command => sub { exit; })->pack(); MainLoop;