-
-
Save abp/2146861 to your computer and use it in GitHub Desktop.
List box model 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
; very basic example of driving a listbox with binding in Seesaw | |
(use 'seesaw.core) | |
(require '[seesaw.bind :as b]) | |
; create a text box and a listbox next to each other | |
(defn make-ui [] | |
(frame | |
:size [400 :by 400] | |
:content (left-right-split | |
(scrollable (text :id :text :multi-line? true)) | |
(scrollable (listbox :id :list)) | |
:divider-location 1/2))) | |
(defn add-behaviors [root] | |
(b/bind | |
; whenever the text box is changed | |
(select root [:#text]) | |
; split the text on commas | |
(b/transform (fn [s] (seq (.split s "\\s*,\\s*")))) | |
; and show the resulting sequence in the listbox | |
(b/property (select root [:#list]) :model)) | |
root) | |
(invoke-later | |
(-> (make-ui) | |
add-behaviors | |
show!)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment