Seesaw: Clojure + UI
"killing CamelCase, proxy and reify, one class at a time"
Seesaw's experimental and subject to radical change
See the Seesaw Wiki for more detailed docs
Seesaw is a library/DSL for constructing user interfaces in Clojure. It happens to be built on Swing, but please don't hold that against it. It's an experiment to see what I can do to make user interface development funner in Clojure. It's kinda inspired by Shoes, Stuart Sierra's Swing posts, etc. clojure.contrib.swing-utils is useful, but minimal and still means a lot of "Java-in-Clojure" coding.
Here's how you use Seesaw with Leiningen
lein as described and then:
$ lein new hello-seesaw $ cd hello-seesaw
Add Seesaw to
(defproject hello-seesaw "1.0.0-SNAPSHOT" :description "FIXME: write" :dependencies [[org.clojure/clojure "1.2.0"] [org.clojure/clojure-contrib "1.2.0"] [seesaw "1.0.1"]])
Replace the Seesaw version with whatever the latest version tag is in case I forget to update this. See below!
Now edit the generated
(ns hello-seesaw.core (:use seesaw.core)) (defn -main [& args] (invoke-later (frame :title "Hello", :content "Hello, Seesaw", :on-close :exit)))
Now run it:
$ lein run -m hello-seesaw.core
NOTE: As mentioned above, Seesaw is experimental and changing daily. Thus, there's a good chance that what's on clojars and what's written here are out of sync. Here's how you can run against the bleeding edge of Seesaw:
- Clone Seesaw from github. Fork if you like. Switch to the "develop" branch.
- In your Seesaw checkout, run
lein installto build it
- In your project's
project.cljfile, change the Seesaw version to
X.Y.Z-SNAPSHOTto match whatever's in Seesaw's
- Move along
- A non-trivial example app to see if this stuff holds up
- GridBagLayout needs more work
- Graphics - I'd rather not wrap the entire Java2D API if there's already something out there (maybe processing?) that does that.
- Structural manip - add/remove widgets to containers.
- Selectors - select widgets by class, data, etc.
- Some kind of ToModel protocol for auto-converting Clojure data-structures to Swing models.
- Investigate how a framework like cljque might fit in with Seesaw
Copyright (C) 2011 Dave Ray
Distributed under the Eclipse Public License, the same as Clojure.