在Clojure中做gui的最好方法是什么?

时间:2021-01-20 22:52:11

What is the best way to do GUIs in Clojure?

在Clojure中做gui的最好方法是什么?

Is there an example of some functional Swing or SWT wrapper? Or some integration with JavaFX declarative GUI description which could be easily wrapped to s-expressions using some macrology?

是否有一些功能性Swing或SWT包装器的例子?或者是与JavaFX声明性GUI描述的集成,这些描述可以通过一些宏来很容易地封装到s表达式中?

Any tutorials?

教程吗?

16 个解决方案

#1


116  

I will humbly suggest Seesaw.

我谨建议跷跷板。

Here's a REPL-based tutorial that assumes no Java or Swing knowledge.

这里有一个基于答复的教程,假定您没有Java或Swing知识。


Seesaw's a lot like what @tomjen suggests. Here's "Hello, World":

跷跷板很像@tomjen的建议。这里是“你好,世界”:

(use 'seesaw.core)

(-> (frame :title "Hello"
       :content "Hello, Seesaw"
       :on-close :exit)
  pack!
  show!)

and here's @Abhijith and @dsm's example, translated pretty literally:

下面是@Abhijith和@dsm的例子

(ns seesaw-test.core
  (:use seesaw.core))

(defn handler
  [event]
  (alert event
    (str "<html>Hello from <b>Clojure</b>. Button "
      (.getActionCommand event) " clicked.")))

(-> (frame :title "Hello Swing" :on-close :exit
           :content (button :text "Click Me" :listen [:action handler]))
  pack!
  show!)

#2


32  

Stuart Sierra recently published a series of blog posts on GUI-development with clojure (and swing). Start off here: http://stuartsierra.com/2010/01/02/first-steps-with-clojure-swing

Stuart Sierra最近发表了一系列关于clojure(和swing) gui开发的博客文章。在这里开始:http://stuartsierra.com/2010/01/02/first-steps-with-clojure-swing

#3


16  

If you want to do GUI programming I'd point to Temperature Converter or the ants colony.

如果你想做GUI编程,我会指出温度转换器或蚁群。

Many things in Swing are done by sub-classing, particularly if you are creating custom components. For that there are two essential functions/macros: proxy and gen-class.

Swing中的许多事情都是通过子类化来完成的,尤其是在创建自定义组件时。为此,有两个基本的函数/宏:代理和gen类。

Now I understand where you are going with the more Lispy way. I don't think there's anything like that yet. I would strongly advise against trying to build a grandiose GUI-building framework a-la CLIM, but to do something more Lispy: start writing your Swing application and abstract out your common patterns with macros. When doing that you may end up with a language to write your kind of GUIs, or maybe some very generic stuff that can be shared and grow.

现在我明白你的意思了。我想现在还没有这样的东西。我强烈建议不要尝试构建一个宏伟的gui构建框架,但是要做一些更简单的事情:开始编写Swing应用程序,用宏抽象出常见的模式。当你这样做的时候,你可能会用一种语言来编写你的gui,或者一些非常通用的东西,可以被共享和增长。

One thing you lose when writing the GUIs in Clojure is the use of tools like Matisse. That can be a strong pointing to write some parts in Java (the GUI) and some parts in Clojure (the logic). Which actually makes sense as in the logic you'll be able to build a language for your kind of logic using macros and I think there's more to gain there than with the GUI. Obviously, it depends on your application.

在Clojure中编写gui时,您会丢失一件事情,那就是使用像Matisse这样的工具。用Java (GUI)编写一些部分,用Clojure(逻辑)编写一些部分,这是一个强有力的指向。这在逻辑上是有意义的,因为你可以用宏来构建一种逻辑,我认为在这里要比使用GUI获得更多的好处。显然,这取决于您的应用程序。

#4


14  

From this page:

从这个页面:

(import '(javax.swing JFrame JButton JOptionPane)) ;'
(import '(java.awt.event ActionListener))          ;'

(let [frame (JFrame. "Hello Swing")
     button (JButton. "Click Me")]
 (.addActionListener button
   (proxy [ActionListener] []
     (actionPerformed [evt]
       (JOptionPane/showMessageDialog  nil,
          (str "<html>Hello from <b>Clojure</b>. Button "
               (.getActionCommand evt) " clicked.")))))

 (.. frame getContentPane (add button))

 (doto frame
   (.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE)
   .pack
   (.setVisible true)))

print("code sample");

And, of course, it would be worth looking at the interoperability section of clojure's website.

当然,也有必要看看clojure网站的互操作性部分。

#5


13  

Nobody yet suggested it, so I will: Browser as UI platform. You could write your app in Clojure, including an HTTP server and then develop the UI using anything from HTML to hiccup, ClojureScript and any of the billions of JS libaries you need. If you wanted consistent browser behaviour and "desktop app look'n'feel" you could bundle chrome with your app.

还没有人提出,所以我将:浏览器作为UI平台。您可以使用Clojure编写应用程序,包括一个HTTP服务器,然后使用从HTML到hiccup、ClojureScript和任何您需要的数十亿个JS libaries来开发UI。如果你想要一致的浏览器行为和“桌面应用程序的外观”,你可以把chrome和你的应用捆绑在一起。

This seems to be how Light Table is distributed.

这似乎就是轻表的分布方式。

#6


8  

There is a wrapper for MigLayout in clojure contrib. You can also take a look http://gist.github.com/261140. I am basically putting up whatever code I am writing as I am learning swing/miglayout.

在clojure后悔中有一个错误布局的包装。您也可以查看http://gist.github.com/261140。当我学习swing/miglayout时,我基本上都是在编写代码。

dsm's example re-written in a lispy way using contrib.swing-utils

《精神疾病诊断与统计手册》(dsm)的例子用的是一种使用方法。

(ns test
      (:import (javax.swing JButton JFrame))
      (:use (clojure.contrib
          [swing-utils :only (add-action-listener)])))

    (defn handler
      [event]
      (JOptionPane/showMessageDialog nil,
        (str "<html>Hello from <b>Clojure</b>. Button "
          (.getActionCommand event) " clicked.")))

    (let [ frame (JFrame. "Hello Swing") 
           button (JButton. "Click Me")  ]
      (add-action-listener button handler)
        (doto frame
          (.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE)
          (.add button)
          (.pack)
          (.setVisible true)))

#7


6  

There's been talk on the mailing list about a few Cells (a la Kenny Tilton's Cells) implementations. It's a pretty neat way to do GUI programming.

邮件列表中有关于一些单元格(类似于Kenny Tilton的单元格)实现的讨论。这是一种很好的GUI编程方式。

#8


5  

I would rather go for clojurefx, it is a bit premature, but it does work and saves you time.

我宁愿选择clojurefx,这有点为时过早,但它确实有效,节省了您的时间。

I started my GUI with seesaw and then tried another component in clojurefx.

我用跷跷板开始我的GUI,然后在clojurefx中尝试另一个组件。

I have finished both, and I am convinced that I am going to refactor the seesaw one to clojurefx.

我已经完成了这两个步骤,我确信我将重构跷跷板1到clojurefx。

After all, JavaFX is the way to go forward.

毕竟,JavaFX是前进的道路。

It feels lighter than seesaw. Or at least, writing it..

它摸起来比跷跷板轻。或者至少写下来。

Bindings work, listeners work, most of the component work, otherwise, just use one of the macros to create a constructor for that particular case and job done. Or, if you find it difficult, write some methods in Java and ask for help to improve clojurefx.

绑定工作,监听器工作,大部分组件工作,否则,只需要使用一个宏来为特定的情况和工作创建构造函数。或者,如果您觉得困难,可以用Java编写一些方法,并请求帮助改进clojurefx。

The guy who wrote clojurefx is busy at the moment, but you can fork the project and do some fixes.

写clojurefx的人现在很忙,但您可以将项目分成几个部分,并进行一些修复。

#9


4  

Here is another very basic swing wrapping example.

这是另一个非常基本的swing包装示例。

; time for some swing
(import '(javax.swing JFrame JTable JScrollPane))
(import '(javax.swing.table DefaultTableModel))

(let 
  [frame (JFrame. "Hello Swing")
    dm (DefaultTableModel.)
      table (JTable. dm)
        scroll (JScrollPane. table)]
  (doto dm
      (.setNumRows 30)
        (.setColumnCount 5))
  (.. frame getContentPane (add scroll))
    (doto frame
      (.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE) 
        (.pack)
        (.setVisible true)))

#10


3  

I asked myself the same question of writing a GUI in Clojure with Swing and came up with this library:

我问自己同样的问题:用Swing在Clojure中编写GUI,然后我想到了这个库:

https://github.com/jonasseglare/signe

https://github.com/jonasseglare/signe

It lets you use represent your domain model as a single Clojure data structure wrapped inside an atom.

它允许您将域模型表示为包装在atom中的单个Clojure数据结构。

See the examples here: https://github.com/jonasseglare/signe/blob/master/src/signe/examples.clj

参见这里的示例:https://github.com/jonasseglare/signe/blob/master/src/signe/examples.clj

#11


2  

I've been developing a Java applet in which everything is written in Clojure except the applet code, which is written in Java. The applet invokes the Clojure code's callbacks of init, paint, etc from java's hooks for those methods that are defined by the applet model. So the code ends up being 99.999 percent Clojure and you don't have to think about the tiny Java piece at all for the most part.

我一直在开发一个Java applet,其中所有内容都是用Clojure编写的,除了用Java编写的applet代码。applet从java的钩子中调用Clojure代码对init、paint等的回调,这些方法是由applet模型定义的。所以代码最终是99.999%的Clojure,大多数情况下你根本不需要考虑这个小Java块。

There are some drawbacks to this approach, which I hope to discuss in more detail on the Clojure Google Group. I think the Clojure developers should include a native way of building applications. Presently you can do whatever GUI stuff you like from the REPL, but if you want a deliverable GUI application, it is necessary to write some Java to call the Clojure code. Also, it seems like the architecture of a Java Applet kind of forces you outside of Clojure's more idiomatic best practices, requiring you to use mutable state, etc.

这种方法有一些缺点,我希望在Clojure谷歌组中对此进行更详细的讨论。我认为Clojure开发人员应该包含一种构建应用程序的本地方法。现在,您可以从REPL中执行任何您喜欢的GUI内容,但是如果您想要一个可交付的GUI应用程序,那么有必要编写一些Java来调用Clojure代码。此外,看起来Java Applet的体系结构迫使您在Clojure更惯用的最佳实践之外使用可变状态,等等。

But also, I am not very far along with Clojure yet and it might be the case that it is possible and I just haven't discovered how to do it correctly yet.

但是,我和Clojure的关系还不是很好,这可能是有可能的,我只是还没有找到正确的方法。

#12


2  

So I didn't see Fn-Fx on this list, from Timothy Baldridge (halgiri). This is a Clojure library providing a functional abstraction over JavaFX.

所以我没有在这个名单上看到Fn-Fx,来自Timothy Baldridge (halgiri)。这是一个Clojure库,提供了对JavaFX的功能抽象。

It can be found on Github at https://github.com/halgari/fn-fx.

可以在Github上找到它,网址是https://github.com/halgari/fn-fx。

To use, make sure you are using a recent version of Java (1.8 90+) and add a dependency to the github repo by adding the following to your project.clj:

要使用,请确保您正在使用最新版本的Java(1.8 90+),并向github repo添加以下内容:

:plugins [[lein-git-deps "0.0.1-SNAPSHOT"]] :git-dependencies [["https://github.com/halgari/fn-fx.git"]]

:插件[[[lein-git-deps " 0.01 - snapshot "]:git依赖性[[["https://github.com/halgari/fn-fx.git]]]

I have tried it, and it works out of the box.

我已经试过了,而且效果很好。

#13


1  

Clojure and SWT is the best approach for doing GUI(s). Essentially, SWT is a plug and play style approach for developing software.

Clojure和SWT是处理GUI的最佳方法。从本质上说,SWT是一种即插即用的软件开发方法。

#14


1  

I don't think there is an official one, but personally I would take advantage of the fact that I am using one of the most powerful language in the world and just imagine what the perfect gui code would look like:

我不认为有官方的,但我个人认为我正在使用世界上最强大的语言之一,想象一下完美的gui代码会是什么样子:

(form {:title :on-close dispose :x-size 500 :y-size 450}
  [(button {:text "Close" :id 5 :on-click #(System/exit 0) :align :bottom})
   (text-field {:text "" :on-change #(.println System/out (:value %)) :align :center})
   (combo-box {:text "Chose background colour" :on-change background-update-function
               :items valid-colours})])

Your idea would differ but this should hopefully the above gives you some idea.

你的想法会有所不同,但希望以上能给你一些启发。

#15


1  

I know that you are hinting for classical desktop solutions, but web fits quite well with clojure. I've written a complete audio application where everything is hooked up so that if you add music to the audio folder it is reflected in the web UI. Just saying that Desktop application isn't the only way :)

我知道你在暗示经典的桌面解决方案,但是web非常适合clojure。我已经编写了一个完整的音频应用程序,在这个应用程序中,所有内容都是连接在一起的,因此如果您将音乐添加到音频文件夹中,它将反映在web UI中。只是说桌面应用程序不是唯一的方法:)

#16


1  

My preferred Clojure UI environment uses IO.js (Node for ES6) + Electron (Container) + Quiescent (ReactJS wrapper).

我喜欢的Clojure UI环境使用IO。js (ES6的节点)+电子(容器)+静默(堆js包装)。

#1


116  

I will humbly suggest Seesaw.

我谨建议跷跷板。

Here's a REPL-based tutorial that assumes no Java or Swing knowledge.

这里有一个基于答复的教程,假定您没有Java或Swing知识。


Seesaw's a lot like what @tomjen suggests. Here's "Hello, World":

跷跷板很像@tomjen的建议。这里是“你好,世界”:

(use 'seesaw.core)

(-> (frame :title "Hello"
       :content "Hello, Seesaw"
       :on-close :exit)
  pack!
  show!)

and here's @Abhijith and @dsm's example, translated pretty literally:

下面是@Abhijith和@dsm的例子

(ns seesaw-test.core
  (:use seesaw.core))

(defn handler
  [event]
  (alert event
    (str "<html>Hello from <b>Clojure</b>. Button "
      (.getActionCommand event) " clicked.")))

(-> (frame :title "Hello Swing" :on-close :exit
           :content (button :text "Click Me" :listen [:action handler]))
  pack!
  show!)

#2


32  

Stuart Sierra recently published a series of blog posts on GUI-development with clojure (and swing). Start off here: http://stuartsierra.com/2010/01/02/first-steps-with-clojure-swing

Stuart Sierra最近发表了一系列关于clojure(和swing) gui开发的博客文章。在这里开始:http://stuartsierra.com/2010/01/02/first-steps-with-clojure-swing

#3


16  

If you want to do GUI programming I'd point to Temperature Converter or the ants colony.

如果你想做GUI编程,我会指出温度转换器或蚁群。

Many things in Swing are done by sub-classing, particularly if you are creating custom components. For that there are two essential functions/macros: proxy and gen-class.

Swing中的许多事情都是通过子类化来完成的,尤其是在创建自定义组件时。为此,有两个基本的函数/宏:代理和gen类。

Now I understand where you are going with the more Lispy way. I don't think there's anything like that yet. I would strongly advise against trying to build a grandiose GUI-building framework a-la CLIM, but to do something more Lispy: start writing your Swing application and abstract out your common patterns with macros. When doing that you may end up with a language to write your kind of GUIs, or maybe some very generic stuff that can be shared and grow.

现在我明白你的意思了。我想现在还没有这样的东西。我强烈建议不要尝试构建一个宏伟的gui构建框架,但是要做一些更简单的事情:开始编写Swing应用程序,用宏抽象出常见的模式。当你这样做的时候,你可能会用一种语言来编写你的gui,或者一些非常通用的东西,可以被共享和增长。

One thing you lose when writing the GUIs in Clojure is the use of tools like Matisse. That can be a strong pointing to write some parts in Java (the GUI) and some parts in Clojure (the logic). Which actually makes sense as in the logic you'll be able to build a language for your kind of logic using macros and I think there's more to gain there than with the GUI. Obviously, it depends on your application.

在Clojure中编写gui时,您会丢失一件事情,那就是使用像Matisse这样的工具。用Java (GUI)编写一些部分,用Clojure(逻辑)编写一些部分,这是一个强有力的指向。这在逻辑上是有意义的,因为你可以用宏来构建一种逻辑,我认为在这里要比使用GUI获得更多的好处。显然,这取决于您的应用程序。

#4


14  

From this page:

从这个页面:

(import '(javax.swing JFrame JButton JOptionPane)) ;'
(import '(java.awt.event ActionListener))          ;'

(let [frame (JFrame. "Hello Swing")
     button (JButton. "Click Me")]
 (.addActionListener button
   (proxy [ActionListener] []
     (actionPerformed [evt]
       (JOptionPane/showMessageDialog  nil,
          (str "<html>Hello from <b>Clojure</b>. Button "
               (.getActionCommand evt) " clicked.")))))

 (.. frame getContentPane (add button))

 (doto frame
   (.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE)
   .pack
   (.setVisible true)))

print("code sample");

And, of course, it would be worth looking at the interoperability section of clojure's website.

当然,也有必要看看clojure网站的互操作性部分。

#5


13  

Nobody yet suggested it, so I will: Browser as UI platform. You could write your app in Clojure, including an HTTP server and then develop the UI using anything from HTML to hiccup, ClojureScript and any of the billions of JS libaries you need. If you wanted consistent browser behaviour and "desktop app look'n'feel" you could bundle chrome with your app.

还没有人提出,所以我将:浏览器作为UI平台。您可以使用Clojure编写应用程序,包括一个HTTP服务器,然后使用从HTML到hiccup、ClojureScript和任何您需要的数十亿个JS libaries来开发UI。如果你想要一致的浏览器行为和“桌面应用程序的外观”,你可以把chrome和你的应用捆绑在一起。

This seems to be how Light Table is distributed.

这似乎就是轻表的分布方式。

#6


8  

There is a wrapper for MigLayout in clojure contrib. You can also take a look http://gist.github.com/261140. I am basically putting up whatever code I am writing as I am learning swing/miglayout.

在clojure后悔中有一个错误布局的包装。您也可以查看http://gist.github.com/261140。当我学习swing/miglayout时,我基本上都是在编写代码。

dsm's example re-written in a lispy way using contrib.swing-utils

《精神疾病诊断与统计手册》(dsm)的例子用的是一种使用方法。

(ns test
      (:import (javax.swing JButton JFrame))
      (:use (clojure.contrib
          [swing-utils :only (add-action-listener)])))

    (defn handler
      [event]
      (JOptionPane/showMessageDialog nil,
        (str "<html>Hello from <b>Clojure</b>. Button "
          (.getActionCommand event) " clicked.")))

    (let [ frame (JFrame. "Hello Swing") 
           button (JButton. "Click Me")  ]
      (add-action-listener button handler)
        (doto frame
          (.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE)
          (.add button)
          (.pack)
          (.setVisible true)))

#7


6  

There's been talk on the mailing list about a few Cells (a la Kenny Tilton's Cells) implementations. It's a pretty neat way to do GUI programming.

邮件列表中有关于一些单元格(类似于Kenny Tilton的单元格)实现的讨论。这是一种很好的GUI编程方式。

#8


5  

I would rather go for clojurefx, it is a bit premature, but it does work and saves you time.

我宁愿选择clojurefx,这有点为时过早,但它确实有效,节省了您的时间。

I started my GUI with seesaw and then tried another component in clojurefx.

我用跷跷板开始我的GUI,然后在clojurefx中尝试另一个组件。

I have finished both, and I am convinced that I am going to refactor the seesaw one to clojurefx.

我已经完成了这两个步骤,我确信我将重构跷跷板1到clojurefx。

After all, JavaFX is the way to go forward.

毕竟,JavaFX是前进的道路。

It feels lighter than seesaw. Or at least, writing it..

它摸起来比跷跷板轻。或者至少写下来。

Bindings work, listeners work, most of the component work, otherwise, just use one of the macros to create a constructor for that particular case and job done. Or, if you find it difficult, write some methods in Java and ask for help to improve clojurefx.

绑定工作,监听器工作,大部分组件工作,否则,只需要使用一个宏来为特定的情况和工作创建构造函数。或者,如果您觉得困难,可以用Java编写一些方法,并请求帮助改进clojurefx。

The guy who wrote clojurefx is busy at the moment, but you can fork the project and do some fixes.

写clojurefx的人现在很忙,但您可以将项目分成几个部分,并进行一些修复。

#9


4  

Here is another very basic swing wrapping example.

这是另一个非常基本的swing包装示例。

; time for some swing
(import '(javax.swing JFrame JTable JScrollPane))
(import '(javax.swing.table DefaultTableModel))

(let 
  [frame (JFrame. "Hello Swing")
    dm (DefaultTableModel.)
      table (JTable. dm)
        scroll (JScrollPane. table)]
  (doto dm
      (.setNumRows 30)
        (.setColumnCount 5))
  (.. frame getContentPane (add scroll))
    (doto frame
      (.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE) 
        (.pack)
        (.setVisible true)))

#10


3  

I asked myself the same question of writing a GUI in Clojure with Swing and came up with this library:

我问自己同样的问题:用Swing在Clojure中编写GUI,然后我想到了这个库:

https://github.com/jonasseglare/signe

https://github.com/jonasseglare/signe

It lets you use represent your domain model as a single Clojure data structure wrapped inside an atom.

它允许您将域模型表示为包装在atom中的单个Clojure数据结构。

See the examples here: https://github.com/jonasseglare/signe/blob/master/src/signe/examples.clj

参见这里的示例:https://github.com/jonasseglare/signe/blob/master/src/signe/examples.clj

#11


2  

I've been developing a Java applet in which everything is written in Clojure except the applet code, which is written in Java. The applet invokes the Clojure code's callbacks of init, paint, etc from java's hooks for those methods that are defined by the applet model. So the code ends up being 99.999 percent Clojure and you don't have to think about the tiny Java piece at all for the most part.

我一直在开发一个Java applet,其中所有内容都是用Clojure编写的,除了用Java编写的applet代码。applet从java的钩子中调用Clojure代码对init、paint等的回调,这些方法是由applet模型定义的。所以代码最终是99.999%的Clojure,大多数情况下你根本不需要考虑这个小Java块。

There are some drawbacks to this approach, which I hope to discuss in more detail on the Clojure Google Group. I think the Clojure developers should include a native way of building applications. Presently you can do whatever GUI stuff you like from the REPL, but if you want a deliverable GUI application, it is necessary to write some Java to call the Clojure code. Also, it seems like the architecture of a Java Applet kind of forces you outside of Clojure's more idiomatic best practices, requiring you to use mutable state, etc.

这种方法有一些缺点,我希望在Clojure谷歌组中对此进行更详细的讨论。我认为Clojure开发人员应该包含一种构建应用程序的本地方法。现在,您可以从REPL中执行任何您喜欢的GUI内容,但是如果您想要一个可交付的GUI应用程序,那么有必要编写一些Java来调用Clojure代码。此外,看起来Java Applet的体系结构迫使您在Clojure更惯用的最佳实践之外使用可变状态,等等。

But also, I am not very far along with Clojure yet and it might be the case that it is possible and I just haven't discovered how to do it correctly yet.

但是,我和Clojure的关系还不是很好,这可能是有可能的,我只是还没有找到正确的方法。

#12


2  

So I didn't see Fn-Fx on this list, from Timothy Baldridge (halgiri). This is a Clojure library providing a functional abstraction over JavaFX.

所以我没有在这个名单上看到Fn-Fx,来自Timothy Baldridge (halgiri)。这是一个Clojure库,提供了对JavaFX的功能抽象。

It can be found on Github at https://github.com/halgari/fn-fx.

可以在Github上找到它,网址是https://github.com/halgari/fn-fx。

To use, make sure you are using a recent version of Java (1.8 90+) and add a dependency to the github repo by adding the following to your project.clj:

要使用,请确保您正在使用最新版本的Java(1.8 90+),并向github repo添加以下内容:

:plugins [[lein-git-deps "0.0.1-SNAPSHOT"]] :git-dependencies [["https://github.com/halgari/fn-fx.git"]]

:插件[[[lein-git-deps " 0.01 - snapshot "]:git依赖性[[["https://github.com/halgari/fn-fx.git]]]

I have tried it, and it works out of the box.

我已经试过了,而且效果很好。

#13


1  

Clojure and SWT is the best approach for doing GUI(s). Essentially, SWT is a plug and play style approach for developing software.

Clojure和SWT是处理GUI的最佳方法。从本质上说,SWT是一种即插即用的软件开发方法。

#14


1  

I don't think there is an official one, but personally I would take advantage of the fact that I am using one of the most powerful language in the world and just imagine what the perfect gui code would look like:

我不认为有官方的,但我个人认为我正在使用世界上最强大的语言之一,想象一下完美的gui代码会是什么样子:

(form {:title :on-close dispose :x-size 500 :y-size 450}
  [(button {:text "Close" :id 5 :on-click #(System/exit 0) :align :bottom})
   (text-field {:text "" :on-change #(.println System/out (:value %)) :align :center})
   (combo-box {:text "Chose background colour" :on-change background-update-function
               :items valid-colours})])

Your idea would differ but this should hopefully the above gives you some idea.

你的想法会有所不同,但希望以上能给你一些启发。

#15


1  

I know that you are hinting for classical desktop solutions, but web fits quite well with clojure. I've written a complete audio application where everything is hooked up so that if you add music to the audio folder it is reflected in the web UI. Just saying that Desktop application isn't the only way :)

我知道你在暗示经典的桌面解决方案,但是web非常适合clojure。我已经编写了一个完整的音频应用程序,在这个应用程序中,所有内容都是连接在一起的,因此如果您将音乐添加到音频文件夹中,它将反映在web UI中。只是说桌面应用程序不是唯一的方法:)

#16


1  

My preferred Clojure UI environment uses IO.js (Node for ES6) + Electron (Container) + Quiescent (ReactJS wrapper).

我喜欢的Clojure UI环境使用IO。js (ES6的节点)+电子(容器)+静默(堆js包装)。