Created
January 22, 2014 07:08
-
-
Save daveray/8554640 to your computer and use it in GitHub Desktop.
Seesaw radio button binding example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use 'seesaw.core) | |
(require '[seesaw.bind :as b]) | |
(def f (let [bg (button-group) | |
f (-> (frame :title "test" | |
:content (border-panel :center (text :id :text :text "hi") | |
:south (horizontal-panel :items | |
[(radio :group bg :text "enabled") | |
(radio :group bg :text "disabled")]))) | |
pack! | |
show!)] | |
(b/bind (b/selection bg) | |
; when a radio button is clicked the selection temporarily goes to nil | |
; so filter those out | |
(b/filter identity) | |
(b/transform #(= "enabled" (text %))) | |
(b/property (select f [:#text]) :enabled?)) | |
f)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment