Dear Monks,

I am curretly developing a Mega-Widget that gets some additional configuration parameter. (Files from which data is parsed). The user can defined some lists of data he wants to edit with this data. When the user finished editing the data, He can click "Ok" and another routine is supposed to manipulate the data based on the user input.

To call the function for this processing outside the dialog, I need to get the settings out. However I am not sure which is the right way. I describe a couple of ways that came to mind and would like to get your comments.

The parameter way

This would be something like:
sub Populate{ ... $self->ConfigSpecs( -infile => [ qw/METHOD infile INFILE]); $self->{ _configX } = []; ... }
The Data would be accesst as:
process( $dlg->{ _configX } );
This way seems to be a bit cumbersome to me.

The PASSIVE Way

This would be something like:
sub Populate{ ... $self->ConfigSpecs( -infile => [ qw/METHOD infile INFILE], -configx => [ qw/PASSIVE configx CONFIGX] ); ... }
The Data would be accesst as:
$config = []; $dlg->configure( -configx => $config ); process( $dlg->cget( "-configx" ) );
This is slightly more "Tk"-Like to me but it fails if the user does not pass a -configx argument.

The METHOD Way

This would be something like:
sub Populate{ ... $self->ConfigSpecs( -infile => [ qw/METHOD infile INFILE], -configx => [ qw/METHOD configx CONFIGX] ); $self->{ _configX } = []; ... } sub configx { # get configX on configure; # return configX on cget; }
The Data would be accesst as:
$config = []; $dlg->configure( -configx => $config ); process( $dlg->cget( "-configx" ) );
This overcomes the problem of setting the variable, but the user never ever really needs to set configX it just comes out it should always start being empty. I am really looking for a way to get data out of a dialog but not at any point in there.

I appreciate all comments on the above listings. People that point me to good widgets I could use as a read for now or other suggestions.


Cheers,
PerlingTheUK

In reply to TK Mega Widget and User Edit by PerlingTheUK

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.