Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: adding a plus button to change perl GUI dynamically during press (Perl TK)

by choroba (Cardinal)
on Aug 23, 2016 at 07:51 UTC ( [id://1170215]=note: print w/replies, xml ) Need Help??


in reply to adding a plus button to change perl GUI dynamically during press (Perl TK)

I've already told you twice that the code in a question should only contain the relevant parts. I haven't tried your code, but I created a short example that does what you want: It features a + button that adds new entries to existing ones.

The trick is to use a subroutine for the repeated code:

#!/usr/bin/perl use warnings; use strict; use Tk; sub create_entry { my ($parent, $entries) = @_; push @$entries, undef; $parent->Entry(-textvariable => \$entries->[$#$entries]) ->pack; } my $mw = 'Tk::MainWindow'->new(-title => 'Adding entries'); my $frame = $mw->Frame->pack; my @entries; create_entry($frame, \@entries) for 1 .. 4; $mw->Button(-text => '+', -command => [ \&create_entry, $frame, \@entries ])->pack; $mw->Button(-text => 'Done', -command => sub { $mw->DESTROY })->pack; MainLoop(); print "$_\n" for @entries;
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-20 02:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found