I couldn't figure out how to update the node
See How do I change/delete my post?

Would all that would be required to do this be to undraw the current screen (via the forget method?) and then re-draw with the desired buttons

  1. I think (but have not verified) that just using gridForget or packForget would cause a memory leak, for they only remove the widget from screen management; they don't actually get rid of the widget. Calling destroy does both.
  2. You only have to destroy and recreate the affected widgets, if they are all in one Frame or other pack-able container; no need to do the whole screen.

Other than that, you are correct. Here is an implimentation:
#!/usr/bin/perl -w use strict; use Tk; use Tk::Pane; my $mw = MainWindow->new( -title => "SACL Survey" ); my $pane = $mw->Scrolled(qw/Pane -scrollbars osow/)->pack( -expand => 'yes', -fill => 'both', ); my $frame = $pane->Frame->pack(); $mw->Label( -text => "... <insert directions here> ..." )->pack(); my @button_values; my @frame_widgets; sub button_set { my $i = int(shift); my $prev = $i - 1; my $next = $i + 1; my $first = 1; my $last = 30; $prev = $first if $prev < $first; $next = $last if $next > $last; $_->destroy foreach reverse @frame_widgets; @frame_widgets = (); push @frame_widgets, $frame->Label( -text => "Survey Question #$i", )->pack(); push @frame_widgets, $frame->Button( -text => "First", -command => sub { button_set($first) }, )->pack( -side=>'left', ); push @frame_widgets, $frame->Button( -text => "Back to $prev", -command => sub { button_set($prev) }, )->pack( -side=>'left', ); foreach my $j (1..4) { push @frame_widgets, $frame->Radiobutton( -text => $j, -value => $j, -variable => \$button_values[$i-1], )->pack( -side => 'left', ); } push @frame_widgets, $frame->Button( -text => "Forward to $next", -command => sub { button_set($next) }, )->pack( -side => 'left', ); push @frame_widgets, $frame->Button( -text => "Last", -command => sub { button_set($last) }, )->pack( -side => 'left', ); } button_set(1); MainLoop; use Data::Dumper; print Dumper \@button_values;

In reply to Re: A node misplaced. . . by Util
in thread Some beginning Tk help by dimmesdale

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.