What do you make of this? Its not unlike megawidgets

#!/usr/bin/perl -- use strict; use warnings; use Tkx; Main( @ARGV ); exit( 0 ); sub Main { $Tkx::TRACE = 64; my $mw = Tkx::widget->new( "." ); my $f = $mw->new_ttk__frame(); my $textvar = RadiosEntry( $f, 'good', 'morning', 'sunshine' ); $f->g_pack; undef $f; $f = $mw->new_ttk__frame(); my $b = $f->new_button( -text => "Selection" ); $b->configure( -command => [ \&OnButtonTextFromTextvar, $b, $textv +ar ] ); $b->g_pack; $f->new_ttk__label( -text, 'yo', -anchor => "center" )->g_pack; $f->new_ttk__label( -textvariable => $textvar, -anchor => "center" + ) ->g_pack; $f->g_pack; Tkx::MainLoop(); } ## end sub Main sub OnButtonTextFromTextvar { warn "OnButtonTextFromTextvar @_"; my( $button, $textvar ) = @_; $button->configure( -text => join " ", 'Selection = ', $$textvar ) +; } sub RadiosEntry { my( $parent, @radios ) = @_; my $textvar = ""; my $selected; for my $radio ( @radios ) { my $button = $parent->new_ttk__radiobutton( -text => $radio, -value => $radio, ); $button->configure( -command => [ \&OnRadioButtonSetTextSetSelected, , $button, \$textvar, \$selected ], ); $button->g_pack; $radio = $button; ## modify @radios } ## end for my $radio ( @radios) my $ent = $parent->new_ttk__entry( -text => "", ); $ent->g_pack; $ent->g_bind( '<Key>', [ \&OnEntryConfigureRadioValueInvokeSelected, $ent, $radios[-1], \$selected ] ); return \$textvar; } ## end sub RadiosEntry sub OnEntryConfigureRadioValueInvokeSelected { warn "OnEntryConfigureRadioValueInvokeSelected @_"; my( $ent, $radio, $selected ) = @_; $radio->configure( -value, $ent->get ); $selected and $$selected->invoke; } sub OnRadioButtonSetTextSetSelected { my( $button, $textvar, $selected ) = @_; $$textvar = $button->configure( '-value' )->[-1]; $$selected = $button; warn "OnRadioButtonSetTextSetSelected @_ $textvar $selected\n"; } __END__

See also https://www.tcl.tk/man/tcl/TkCmd/ttk_radiobutton.htm


In reply to Re^3: Tkx passing a variable to -value field in radio button by Anonymous Monk
in thread [Tkx] passing a variable to -value field in radio button by Anonymous Monk

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.