ClojureのGUIライブラリseesawでMigLayoutを使ってみます。
簡単なツールを作ったときにGUIをでっちあげるのに使えそうです。
(ns seesaw-test.core (:use [seesaw core chooser mig]) (:gen-class)) (defn set-filename [root target] (choose-file :success-fn #(text! (select root [target]) (.getAbsolutePath %2)))) (defn run [] (let [root (frame :title "mig-layout test" :on-close :exit :size [400 :by 200])] (config! root :content (mig-panel ;; [Layout Row Column] :constraints ["fillx" "[][grow,fill][]" ""] :items ; [ウィジェット 設定(省略可)] [["名前:"] ;; wrap で次の行へ進む [(text :id :name :text "name") "wrap"] ["ファイル:"] [(text :id :file :text "file")] [(action :name "選択" :handler (fn [_] (set-filename root :#file))) "wrap"] [(action :name "OK" :handler (fn [_] (alert (str "Name:" (text (select root [:#name])) "\n" "File:" (text (select root [:#file])))))) "span 3, center"]])) root)) (defn -main [& args] (native!) (invoke-later (show! (pack! (run)))))
0 件のコメント:
コメントを投稿