GUIs - A Modest Proposal

Martin v. Loewis martin at v.loewis.de
Wed Jun 9 15:15:16 EDT 2010


Am 09.06.2010 01:54, schrieb Grant Edwards:
> On 2010-06-08, Martin v. Loewis<martin at v.loewis.de>  wrote:
>> Am 08.06.2010 20:15, schrieb Grant Edwards:
>>> On 2010-06-08, Martin v. Loewis<martin at v.loewis.de>   wrote:
>>>>> TkInter ->   Tcl ->   Tk ->   Xlib
>>>>>
>>>>> Is the Tcl intepreter really need to use this GUI? Why not:
>>>>>
>>>>> (Pyton ->) Tkinter-API ->   Xlib ?
>>>>
>>>> Even if this was possible (which it is not)
>>>
>>> Why is it not possible?  It seems to have been done for other
>>> languages.
>>
>> So you don't know for sure? Which implementation specifically
>> do you think of?
>
> There was a Scheme implementation called STk that didn't use Tcl.

That's not true. See, for example, Src/tk-glue.c. It contains functions like

static SCM TkResult2Scheme(Tcl_Interp *interp, int objproc)
{
   SCM res;

   if (objproc) {
     register SCM data = TCLOBJDATA((SCM) Tcl_GetObjResult(interp));
     res = data ? STk_convert_tcl_list_to_scheme(data) : NIL;
   }
   else {
     register char *s = interp->result;
     res = (*s) ? STk_convert_Tcl_string2list(s) : NIL;
   }
   Tcl_ResetResult(interp);

   return res;
}

SCM STk_execute_Tcl_lib_cmd(SCM cmd, SCM args, SCM env, int eval_args)
...

This looks *exactly* like the approach taken in _tkinter to me.

One difference seems to be that they include the full source code of Tcl 
and Tk with the interpreter, so you don't need to download it separately.

The other difference apparently is that they expose Tcl commands as
Scheme functions, so that they can write

(Tk:pack [Tk:frame w.top :relief "raised" :bd 1] :expand #t :fill "both")

However, this still uses a Tcl_Interp object during evaluation.

Regards,
Martin




More information about the Python-list mailing list