embedding stubbed tcl

Paul Duffin pduffin at mailserver.hursley.ibm.com
Mon Nov 8 06:05:58 EST 1999


Robin Becker wrote:
> 
> In article <3821E345.FC6C372F at chello.nl>, Jan Nijtmans
> <j.nijtmans at chello.nl> writes
> >Robin Becker wrote:
> >
> >> I thought stubs were for extensions. The tkinter case is slightly the
> >> wrong way round as it starts tcl up.
> >
> >Stubs can very well be used for applications as well. For example,
> >I already used it to Stubify the Tcl plugin, so I don't need to
> >recompile it when Tcl8.3 comes out ;-).  The only problem is that
> >Tcl doesn't yet contain a portable way to use dlopen()/LoadLibrary()
> >or whatever this function might be called.
> >
> ok so what is the minimal way to do this?

Does tkinter call Tk_Main (doubtful) ?
I would suggest that you do something like.

	hTcl = dlopen (whatever version of Tcl)
	createInterp = dlsym (hTcl, "Tcl_CreateInterp");
	interp = createInterp ();
	Tcl_InitStubs (interp, "version", ...);

If Tk was a dynamically loadable package then you could do something
like

	Tcl_PkgRequire (interp, "Tk", "version", ...);

Otherwise you have to do

	hTk = dlopen (whatever version of Tk)
	tkInit = dlsym (hTk, "Tk_Init")
	tkSafeInit = dlsym (hTk, "Tk_SafeInit")
	tkInit (interp);
	Tcl_StaticPackage (tkInit, tkSafeInit, "Tk", "version")

At this point you now have a working Tcl and Tk. How you actually choose
the version of Tcl and Tk to use is up to you.

-- 
Paul Duffin
DT/6000 Development	Email: pduffin at hursley.ibm.com
IBM UK Laboratories Ltd., Hursley Park nr. Winchester
Internal: 7-246880	International: +44 1962-816880




More information about the Python-list mailing list