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

Hi,
I'm trying to puzzle out how to configure values in a Tkx combobox. (I am also trying to learn Tkx by programming by example.) I can make pretty comboboxes in a frame and grid them and populate them with ranges of values:
my @days = (1 .. 31); Tkx::ttk__combobox(".app.date.day", -values => \@days, -textvariable => \$d,); Tkx::grid(".app.date.day", -column => 0, -row => 2, -columnspan => 1, -rowspan => 1, -sticky => "nsew");

but when I try to change the values
@days = qw(1 .. 28); Tkx::ttk__configure(".app.date.day", -values => \@days,);

I get the error message:
invalid command name "ttk::configure"

Doesn't work for Tkx::configure either. The Tk docs indicate that configure is the correct way to change -values, but I'm darned if I can make it work.

I'm running ActiveState Perl 5.10 on WinXP with the Tkx 1.05 module.

I'm losing my mind trying to interpret the doc on www.tcl.tk so if anyone wiser than I has an idea which direction to bang my head, I'd appreciate it.

Replies are listed 'Best First'.
Re: Tkx - configure ttk::combobox
by gisle (Novice) on Jan 30, 2009 at 11:21 UTC

    I now see how starting the tutorial with examples using literal path names like this makes things really confusing as the Tk widgets are really Tcl commands themselves and there is no easy mapping in the Tkx:: namespace to functions that use "." their name. When you in Tcl would say:

    .app.date.day configure -values {1 2 3 ... 28}

    then the literal translation into Tkx would be:

    Tkx::.app.date.day_configure(-values => [1..28]);

    but this does not work since you can't use "." in identifiers in Perl. One way to fix this is to quote the function name and write:

    &{"Tkx::.app.date.day_configure"}(-values => [1..28]);

    which will work, but is just beyond ugly.

    The only sane way to work with widgets in Tkx is to create Tkx::widget objects, making you code:

    my $day = $date->new_ttk__combox( -values => \@days, -textvariable => \$d, ); Tkx::grid($day, ....); @days = (1 .. 28); $day->configure(-values => \@days);

    I'll try to add some text to the Tkx docs to make this clearer.

      Thanks, quoting the function works. It may not be elegant but if it works... although if I wind up with lots of them I'll probably have to bite the bullet and rewrite the app with objects, which is probably a little beyond this Perl Postulant.
Re: Tkx - configure ttk::combobox
by Anonymous Monk on Jan 30, 2009 at 05:05 UTC
        Hmm. When I use Tkx::widget::m_configure I get a new error: Can't call method "_mpath" without a package or object reference at C:/Perl/lib/Tkx.pm line 165.