简体   繁体   English

如何设计主要运行tcl脚本的C ++ GUI应用程序

[英]How to design a C++ GUI application that mostly runs tcl script

I am looking for a good approach to build a C++ GUI application. 我正在寻找一种构建C ++ GUI应用程序的好方法。 Its core is generating whole bunch of tcl code and execute it through Tcl C++ API ( #include <tcl.h> ). 它的核心是生成一堆tcl代码,并通过Tcl C ++ API( #include <tcl.h> )执行它。 The GUI provides an easy way for users to complete those tcl scripting tasks. GUI为用户提供了一种简单的方法来完成这些tcl脚本任务。

In other words, inside each callback function associated with the GUI control, it's like using ostringstream to populate tcl code and passes it to tcl interpreter. 换句话说,在与GUI控件关联的每个回调函数中,就像使用ostringstream填充tcl代码并将其传递给tcl解释器一样。 Eg: 例如:

bool execTclProc1(options) {
  ostringstream oss;
  oss << "package require MyPackage \n";
  string optionsForTcl = genOptionsForTcl(options);
  oss << "myTclProc1 " << optionsForTcl << endl;

  if(Tcl_Eval(interp, oss.c_str() == TCL_OK) {
    // print out some messages to the GUI message window
  }

  ...
}

The down side of this design: 此设计的缺点:

  • Hard to debug tcl code error. 难以调试tcl代码错误。 Since every change in tcl code needs to re-compile the C code. 由于tcl代码的每一次更改都需要重新编译C代码。 Although a fast way is to write and test tcl code in tcl interactive shell. 尽管一种快速的方法是在tcl交互式shell中编写和测试tcl代码。 But a lot of tcl code is populated in C++, not hard-coded. 但是很多tcl代码都是用C ++填充的,而不是硬编码的。 So it's not so feasible. 所以它不是那么可行。

  • Whole bunch of tcl code is written in C++ routines. 整个tcl代码都是用C ++例程编写的。 This makes it hard to maintain. 这使其难以维护。

I want to seek some insights from the community. 我想从社区中寻求一些见解。

Can't you use the Tk toolkit called as library functions from C++? 您不能使用C ++中称为库函数Tk工具包吗?

Also, there is Tk/C++ - don't know how good it is. 另外,还有Tk / C ++ -不知道它有多好。 They overloaded operator- and use expression templates so that the C++ code like like Tcl. 他们重载了运算符,并使用了表达式模板,因此C ++代码像Tcl这样。 Pretty cool! 太酷了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM