On 2011-03-30, at 8:48 PM, Diogo F. S. Ramos wrote:
Hello,
I am a really gambit newbie and I was toying with the idea of creating a GUI application with gambit.
Is there some GUI library? By that I mean a widget collection library like GTK+ or QT.
One approach which is portable is to use Tcl/Tk. Check out the examples/tcltk directory. It contains several examples (translations of the examples in the Tcl/Tk book).
As I didn't find one I think it is probably a good idea to use C to drive the GUI part and gambit for the rest.
It depends on the GUI library. In many GUIs there is a main event loop that is part of the GUI API. This can be a problem because that event loop takes over control of the execution, and prevents the Gambit thread scheduler, and timeouts to operate properly. Single-thread programs should be OK.
The "main" program can either be in C or in Scheme (but if in C don't forget to initialize your compiled Scheme code by calling ___setup()). The event handlers and the rest of your GUI logic can be in Scheme. The Scheme code will call the GUI's C API exposed through Gambit's FFI (creating windows, getting the details of an event, etc).
What would be the right way to do it?
Also, I would like to use GTK+, as I'm experienced with it, but it has some requirements, like having control of the main thread and never returning. Would this be a problem?
It is only a problem if you want to use multiple Scheme threads. But a workaround is to hook into "idle" events so that the Scheme event handler calls (thread-yield!), thus allowing the Gambit thread scheduler to give time to the other Scheme threads. This is more or less how the iPhone "Gambit REPL" was implemented (see examples/iOS).
Marc