1

I am trying to create a starkit consisting of multiple tcl source files, which can be executed without problem on my machine with wish. However, on trying to do the same with tclkit, I got this error from one of the second level source files sourced from the toplevel one directly sourced from main.tcl.

unknown or ambiguous item type "waveform"
    while executing
"$c create waveform 0 0 -sound snd -height $v(waveh) -width $v(cWidth)  -tags [list obj wave] -debug $::debug -fill $v(wavColor) -limit $v(waveScale)"
    invoked from within
"if $v(showWave) {
    $c create waveform 0 0 -sound snd -height $v(waveh) -width $v(cWidth)  -tags [list obj wave] -debug $::debug -fill $v(wavColor) ..."
    (procedure "Redraw" line 28)
    invoked from within
"Redraw all"
    (procedure "resetDisplay" line 21)
    invoked from within
"resetDisplay"
    (file "MYAPPLICATION.vfs/TOPLEVEL.tcl" line 591)

waveform is from snack library, so I investigated it. The library does not have unresolved external dependency and the error would have occured much earlier if the library could not be used at all, so I have tried the following:

  • Recompile snack library from source
  • Compile snack directly into the tclkit runtime (rather than as a lib in vfs)
  • Add package require snack again into the source file in question
  • Make my application a package in lib rather than in the direct vfs directory

None of the above works. The only working way I have found is to combine all the source files into one by substituting sources. Therefore, I suspect this to be some kind of race condition, but I am neither able to prove it nor to debug it.

Sorry if I am missing anything important here (pretty new to tcl/tk). Would really appreciate any suggestions. Thanks very much in advance! :)

SuibianP
  • 99
  • 1
  • 11
  • Which OS? I can imagine that snack only adds canvas item types if Tk is loaded before snack. When using wish, that is guaranteed. But with a tclkit that may not be the case (except on Windows). – Schelte Bron Jan 09 '21 at 08:43
  • @SchelteBron For the sake of completeness, the OS is Linux (Ubuntu 18.04 LTS, more specifically). The sequence of `require`s is indeed the reason that caused the problem. – SuibianP Jan 09 '21 at 16:45

1 Answers1

2

Snack is primarily a sound toolkit. It adds a snack::sound command to Tcl for working with audio (playback, recording, etc.). When used in combination with Tk, it also adds a waveform item type to the Tk canvas. For this to work, Tk has to be loaded before snack. When using wish, Tk is loaded from the start. But with a tclkit (unless running on windows), Tk has to be loaded with a package require Tk command.

I can reproduce your error using the following code:

package require snack
package require Tk

snack::sound snd
snd read foo.wav

canvas .c
.c create waveform 0 0 -sound snd

The error goes away when I swap the first two lines around. So:

package require Tk
package require snack
Schelte Bron
  • 4,113
  • 1
  • 7
  • 13
  • It solves the problem. It was really silly of me not being able to identify the problem XwX Thank you so much for your kind guidance! I have marked the answer as accepted and will cast the upvote once I earn enough reputation points. (Sorry for that, I am still very new here (^_^;) ) – SuibianP Jan 09 '21 at 16:40