Reputation: 2578
I have developed GUIs before in Matlab using the GUI toolbox, and right now I am using common lisp for my project. I need to develop a GUI which may probably have a push button, radio button, a figure window etc.
I just want to know whether it is feasible to do this in Common Lisp and whether there are toolboxes, libraries that are fairly easy to use and learn. I don't have a strong programming background so I will try to avoid advanced stuff, if possible.
Thank you very much in advance.
Upvotes: 13
Views: 8263
Reputation: 14291
Besides the already mentioned LTK (which always worked fine for me), I am also fond of Cells-Gtk, because Tilton's Cells are, in my opinion, a nice approach to writing GUI code. (Still, LTK might be easier to get started with.)
For example, here is some code for a very simple Fahrenheit/Celsius (and vice versa) converter I wrote when I was just starting out with Cells-Gtk:
(defun fahrenheit->celsius (fahrenheit/string)
(princ-to-string (handler-case
(* (- (read-from-string fahrenheit/string nil) 32) 5/9)
(error () "NaN"))))
(defun celsius->fahrenheit (celsius/string)
(princ-to-string (handler-case
(+ (* (read-from-string celsius/string nil) 9/5) 32)
(error () "NaN"))))
(defmd celsius-fahrenheit-converter (gtk-app)
:title "°C <-> °F"
:position :center
:kids
(kids-list?
(mk-vbox
:kids
(kids-list?
(mk-hbox
:kids
(kids-list?
(mk-entry :md-name :celsius
:init "0"
:text (c? (fahrenheit->celsius (widget-value :fahrenheit))))
(mk-label :text "°C")))
(mk-hbox
:kids
(kids-list?
(mk-entry :md-name :fahrenheit
:text (c? (celsius->fahrenheit (widget-value :celsius))))
(mk-label :text "°F")))))))
There is no "Calculate" button or something like that – just change the value of one entry field and the other one will be updated on the fly. As you can see, Cells handles the state changes of the widgets autmatically – only the correct "plumbing" must be given.
(This code is a few years old, and I have no Cells-Gtk installation to test it ATM, but it used to work properly when I wrote it.)
Upvotes: 1
Reputation: 679
I've played around with a few of the suggestions so far, in my experience the Qt and Gtk bindings get the job done, but they still feel a bit C/C++-ish, which I don't like. I did play around with the free version of LispWorks and I was pretty impressed with CAPI, but I have no need(and ability) to invest in a commercial license at this point so I've never done anything other than playing around with the example apps.
I will second the recommendation to look into web based UIs. As much as I dislike programming the browser, there are a lot of tools these days to make it tolerable, and maybe even enjoyable, and Restas(a framework based on Hunchentoot) is pretty sweet.
Upvotes: 1
Reputation: 3060
I second the suggestion to use LTK.
However, if your requirements grow beyond what LTK provides (and you can afford spending some time learning basic JavaScript+HTML+CSS - that probably means not avoiding the "advanced stuff" you mention in the question), you might find it useful to make a web interface for your application.
Because I could not find a free decent alternative to writing portable GUIs in CL, I decided to write web apps instead of desktop apps (and use them as desktop apps - that is, start the server on the computer where I mean to use the application, open the page in a browser and treat it as a desktop app; if there's something I can't do in JavaScript, such as access the network etc., I do it on the server). This has the advantage of great portability (right now this means I develop on Linux using SBCL and deploy on Windows using Clozure CL, and it works great so far).
I'm currently quite happy with the progress on such an application, using Hunchentoot (to host the content) + Parenscript (to CLize JavaScript) + JQuery (to tame browser incompatibilities) + JQueryUI (to tame writing UI in browsers). Don't worry about JS performance, it's pretty spectacular these days (well, if you can afford to ignore IEs earlier than IE9 and use a recent browser). A few weeks ago I wrote a simple 'hello world'-type application using all of these (except JQueryUI, but that's easy to add); it might be useful as a minimal example of what I mean.
Upvotes: 10
Reputation: 9451
Take a look at LTK, which is a wrapper for interfacing with the Tk GUI toolkit. It's pretty easy to get started with it and it should suffice for simple application.
Upvotes: 7
Reputation: 31053
If you are in a Unix-ish environment, you might want to try cl-gtk2 or commonqt or even CLIM. Besides, your choice of a UI toolkit depends on what Common Lisp implementation you are using. Lisp Works and Allegro CL both come with their own UI toolkits, which work (more or less) platform independent.
Upvotes: 4