joheid
joheid

Reputation: 418

Using Tk widget in command-line application

we just ran into problems related to Tcl and Tk differences.

We have a testing tool for transfered xml data using the tcltest framework.

General program flow:

In a new test we want to include a graphic into the document. So we load Tk in the test-setup, prepare the graph on a canvas and write the canvas to a file. This all works fine in a stand-alone test program.

But integrated into the application we observe, that the test is performed and the program ends without an error at the end of the testfile, but never returns to the main program to perform the last three steps.??? If the remaining code of the application is sourced into the test-file, the program execution continues properly. Anybody an idea what might go wrong?

Thanks in advance joachim

Upvotes: 0

Views: 93

Answers (1)

Donal Fellows
Donal Fellows

Reputation: 137557

When you load Tk, it installs a handler which runs the event loop after your script finishes executing. This is because this is how the wish program has worked for at least 20 years; Tcl is (logically) used to set up the application and handle callbacks. For most GUI applications, this is absolutely fine. In your case not.

You should put an explicit exit at the end of your script once you've finished generating the output you want.

Upvotes: 1

Related Questions