0408 tcl/tk 学习 2

找找资料,看看一些东西:
Tcl简介  http://www.arm8.com/cv/3/4/139.html
TCL/TK 与 C 程序的集成  http://www.arm8.com/cv/3/4/138.html
Tcl与SWIG  http://www.arm8.com/cv/3/4/137.html
Tcl的历史  http://www.arm8.com/cv/3/4/136.html
http://www.arm8.com/cv/3/4/141.html Tcl/Tk 烹调书 – Tcl/Tk 和 C

#define Tk_MainLoop \\
 (tkStubsPtr->tk_MainLoop) /* 0 */

“calling a simple script from C”

#include <stdio.h>
#include <stdlib.h>

#include "tcl.h"
#include "tk.h"

#define QWE fprintf(stderr, "Line %i\\n", __LINE__);

Tcl_Interp* inter;

char* script = "button .b -text \’HW\’ -command exit;\\n"
"button .c -text \’big\’ -command \\".b configure -text hw\\";\\n"
"button .d -text \’small\’ -command \\".b configure -text HW\\";\\n"
"pack .b\\npack .c\\npack .d\\n";

int Tcl_AppInit(Tcl_Interp* in) &leftsign;
        Tcl_Init(in);
        Tk_Init(in);
        Tcl_Eval(in, script);

        return TCL_OK;
&rightsign;

int main(int argc, char** argv) &leftsign;
 Tcl_Interp *inter;

        inter = Tcl_CreateInterp();
 Tcl_FindExecutable(argv[0]);
        Tcl_Init(inter);
        Tk_Init(inter);
        Tcl_Eval(inter, script);
        Tk_MainLoop();
        Tcl_DeleteInterp(inter);
        return 0;
&rightsign;

对于带Tk扩展的初始化,即TcVTk,首先调用的将是
Tk MainO过程,它创建的是带扩展功能的解释器-wish然
后由Tcl Applnit 0过程将Tk命令加入解释器中,这个Tcl
Apphtit0将替代默认的,负责将Tk命令对应的c库与解释
器相链接,完成调用的初始化.所以,它产生的解释器wish
既认识标准TO的内核命令,又认识Tk命令.另外,这个
Tctes Applnit0最后将调用Tk- 1nit0过程,决定初始化结束后
的动作.与标准Tel不同的是I Tcvrk在初始化结束后还将
进入一个由Tk_MainLoop形成的X窗口事件循环,接收和
处理窗口事件.用户还可以用Tk DoOneEvent和Tk Creat-
FileHandle过程建立自己的事件循环,并在Tk_M-Loop中
调用事件处理程序.
NAME
Tk_MainLoop – loop for events until all windows are deleted
SYNOPSIS
#include <tk.h>
Tk_MainLoop()

DESCRIPTION
Tk_MainLoop is a procedure that loops repeatedly calling Tcl_DoOneEvent. It returns only when there are no applications left in this process (i.e. no main windows exist anymore). Most windowing applications will call Tk_MainLoop after initialization; the main execution of the application will consist entirely of callbacks invoked via Tcl_DoOneEvent.

历史博文

标签:,
九月 2, 2006 at 11:59 下午 by yippee 1,039 次
Category: Dev
Tags: ,