over2sd has asked for the wisdom of the Perl Monks concerning the following question:

I'm working on a project in Perl Prima, and I'm having trouble with radio groups.

Even when I copy/paste the example code from the CPAN page on the subject (Buttons and Check Groups) into my code without changes, the group box shows up, but the radio buttons and their text are not shown.

I'm sure I'm doing something wrong, but I don't know what it is. I've built a hack that approximates the functionality for the time being, but I would appreciate enlightenment on this subject so I can go back and do it properly.

Replies are listed 'Best First'.
Re: Invisible Prima::Radio
by Anonymous Monk on Feb 13, 2015 at 21:26 UTC

      Here is a minimally functional (well, not really, but it runs) example of the code from the linked page I mentioned:

      use strict; use warnings; use Prima qw(Application Buttons); my $window = Prima::MainWindow->new( text => "Invisible Radios!", size => [300, 200], ); my $box = $window->insert( Widget => name => "box", pack => { fill => +"both", expand => 1, }, ); # Code straight from http://search.cpan.org/~karasik/Prima-1.41/Prima/ +Buttons.pm # only change is $box instead of $widget my $group = $box-> insert( 'Prima::GroupBox', onRadioClick => sub { print $_[1]-> text, "\n"; } ); $group-> insert( 'Prima::Radio', text => 'Selection 1'); $group-> insert( 'Prima::Radio', text => 'Selection 2', pressed => 1); $group-> index(0); # End of copied code! Prima->run();

      Examining the scripts that do display, I think that the problem is that the example code (and thus, my own) does not contain an origin attribute, without which, it appears the radios do not (properly) display.

      Unfortunately, this attribute is not mentioned anywhere on the page documenting buttons that I linked above (or any other documentation I found in my searching). This is quite sad, as it appears to be a required attribute.

      Thanks for pointing me in the right direction to figure it out.

      index(0); # End of copied code! Prima-