-
-
Save lildata/27b37fd09138188b12ee to your computer and use it in GitHub Desktop.
Clojure/Seesaw busy cursor 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
(ns busy-cursor.core | |
(:use seesaw.core)) | |
(defn long-running-task | |
[] | |
(Thread/sleep 5000) | |
"The result") | |
(defn run-task-with-busy-cursor | |
[c] | |
(config! c :cursor :wait) | |
(future | |
(let [result (long-running-task)] | |
(invoke-later | |
(text! (select c [:#result]) result) | |
(config! c :cursor :default))))) | |
(defn -main | |
[& args] | |
(invoke-later | |
(let [c (border-panel :north (label :id :result :text "Nothing Yet") | |
:center (button :id :click-me :text "Click Me")) | |
f (frame :title "Busy busy busy" :content c :on-close :exit)] | |
(listen (select f [:#click-me]) | |
:action | |
(fn [_] | |
(run-task-with-busy-cursor c))) | |
(pack! f) | |
(show! f)))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment