Context: Windows7, optionally MinGW
I’m thinking of writing a Tk interface for Lhogho. Short of reading the source of Tkinter, how does one write that kind of a wrapper? It’s been done for C++, Perl, Python, Tcl and others.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends on how close you want the mapping to be.
The trivial way is to embed a Tcl interpreter and just call
Tcl_Eval()or one of the other functions of that family with the right Tcl code as strings, thats pretty easy to do when you can link C libraries or DLLs.Once you have that, you can start to make your interface more natural, and for example provide mappings from your languages datastructures to Tcl/Tk internals (Tcl_Obj*), mostly for performance, or to add appropriate wrappers to make the bindings more natural for your language. The main problem usually is to get the event loop working properly with your language.
Have a look at perls tcl::tk module or pythons Tkinter for an example of this.
See:
http://wiki.tcl.tk/13208
A different way to do it was done by PerlTk, which tried to NOT embed a full Tcl interpreter. Works but is much harder to do, as Tk uses a significant amount of Tcl code for the not performance critical parts like default binding scripts etc.
Some examples of embedding Tcl/Tk and discussions can be found at:
http://wiki.tcl.tk/2074