1

Is it possible to create a button, for example, whose callback takes a parameters?

e.g.

button(-text => 'Row1', -command => \&do_something_with('Row 1'));

Tried it on a test program and it doesn't seem to. If that is the case, is there some other way to do what I intend with the example above?

My program needs to create buttons but the number is not known beforehand (depends on a .cfg file).

Colin Wu
  • 611
  • 7
  • 25
  • You should be able to. I don't know the syntax in perl though. A temporary workaround could be to read the file from within the command you are calling? – Jerry Sep 29 '15 at 05:58

2 Answers2

1

You probably need an anonymous subroutine that invokes your subroutine with at least one parameter.

button(-text => 'Row1', -command => sub {do_something_with('Row 1', @_)});
glenn jackman
  • 238,783
  • 38
  • 220
  • 352
0

I failed to understand your question clearly but from what i understood is it something like:

button(-text => 'Row1', -command => \&do_something_with('Row 1'));
ttk::button -text $row -command [list RowOpertaion $row $xyz $abc]

Here RowOperation is a proc with 3 parameters suppose row, abc, xyz. In that proc you can do the needful.

suku007
  • 21
  • 4