1
votes

I have a C++ library that we're using to override some functions for testing. However, we just have it set up to prompt from the command line.

I'm looking to create a GUI for it to use as the prompt rather than command line.

I've been looking into Tcl/Tk, but I'm not quite sure if it can do what I'd like. Is it possible to use the Tcl/Tk wrapper to stylize my library functions?

Can I just include Tcl/Tk in my C++ code somehow, so that I call those functions right inside my library?

2
Do you really mean to mention "Tlc", or did you mean "Tcl"?Bryan Oakley
Yep, you're completely correct. I've edited the post - Thanks!!Josh Johnson

2 Answers

1
votes

Probably easiest to wrap your C++ functions with swig and call them from Tcl, see this intro, then you can use Tk to create a GUI for your input parameters and/or displaying your results.

1
votes

The two mechanisms to consider for this are SWIG and critcl in C++ mode. The former is probably easier to get going with as you already have the C++ code, and the latter produces more natural (more “Tcl-ish”) language embeddings.

Once you've got your library connected up, the first thing to do is probably to write a little test suite (using tcltest, a standard package supplied with Tcl) so that you know that things are working. (That saves a lot of heartache and hair-tearing later on!) If your code is working fine, you'll probably have a good enough test suite within a day or two. Then hook it up to your GUI (Tk is indeed good for that), which can be written safe in the knowledge that it's using a business logic layer that's working fine. I encourage you to avoid putting any GUI code in your C++ code if you can; it's far better to produce a clean interface without entanglements. (OK, it's not always possible to avoid, especially if you're doing heavy visualization, but it's a lot more work…)