It's possible with wxPerl.

wxWidgets makes heavy use of subclassing, so "mega" widgets are not an uncommon occurrence. In fact, with the C++ API you almost always end up sublcassing at least several widgets (typically wxFrames, wxPanels, and wxBoxSizers) to process any significant number of events.

Here's an example of a wxPerl "mega" widget called LabelEntry. It creates a label, a text entry field, and a submit button. When the user clicks the submit button, the text is assigned to the variable specified by the caller and the caller's callback routine is invoked with the mega widget as the only argument. (Note that I've never used wxPerl before, so this will look somewhat rough):

#!/usr/bin/perl -w use strict; use Wx; my $wxobj = new MyApp; $wxobj->MainLoop; package MyApp; use Wx qw(wxOK wxICON_INFORMATION); use base 'Wx::App'; sub OnInit { my $self = shift; my $frame = Wx::Frame->new( undef, -1, 'MegaWidget test', [0, 0], [300, 200] ); $self->SetTopWindow($frame); $frame->Show(1); my $name; my $labentry = LabelEntry->new( $frame, "Your name: ", \$name, "Submit", sub { Wx::MessageBox( "Your name is: $name.", "Name", wxOK|wxICON_INFORMATION, $frame ); } ); return 1; } package LabelEntry; use Wx; use Wx::Event qw(EVT_BUTTON); use base 'Wx::Panel'; sub new { my $invo = shift; my $class = ref $invo || $invo; my ($window, $label, $var_ref, $button_label, $callback) = @_; my $self = $class->SUPER::new($window, -1, [0,0], [300, 30]); bless($self, $class); new Wx::StaticText ($self, -1, $label, [0, 0]); my $text_control = new Wx::TextCtrl ( $self, -1, "", [70, 0] ); my $button_id = 2; my $button = new Wx::Button ( $self, $button_id, $button_label, [170, 0] ); EVT_BUTTON( $self, $button_id, sub { $$var_ref = $text_control->GetLineText(0); $callback->($self); } ); }

In reply to Re: Which GUI libraries allow creation of megawidgets? (wxPerl?Gtk?) by William G. Davis
in thread Which GUI libraries allow creation of megawidgets? (wxPerl?Gtk?) by Courage

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.