in reply to Tkx - configure ttk::combobox

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.

Replies are listed 'Best First'.
Re^2: Tkx - configure ttk::combobox
by Anonymous Monk on Jan 30, 2009 at 14:33 UTC
    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.