tclsh vs wish (tcl/tk)

735 Views Asked by At

I'm trying to run tclsh with my package (shared library) written in C++. The package needs a mechanism similar to Windows PumpMessage to be invoked periodically on the main thread once it is loaded via package req.

With wish, I can simply register a timer handler via Tcl_CreateTimerHandler and it works ok.

With tclsh, the event loop doesn't exist so I cannot hook up from my package. I tried setting up the main loop (Tcl_SetMainLoop) but that gets invoked once and it gets set to NULL afterwards.

Any ideas on how I can achieve this?

1

There are 1 best solutions below

0
On

Got it after looking into the tk code. The main loop needs to do the loop itself (it's not called in a loop as I expected).

If the main loop set into tcl does a while loop, it's working fine.