Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a GUI for creating GUIs in Scala?

Is there something like WindowBuilder for Scala?

like image 954
Łukasz Lew Avatar asked Dec 20 '10 09:12

Łukasz Lew


2 Answers

I don't know of any WYSIWYG GUI builder for Scala. But you don't need one. In fact, strictly speaking, Scala doesn't have a GUI; it just uses the underlying platform's GUI (or GUIs).

So, the JVM port of Scala uses AWT, Swing or SWT and the CLI port of Scala uses WinForms or WPF. I've heard rumors of ports of Scala to the ECMAScript runtime and the Objective-C runtime, and those would presumable use HTML5 and Quartz/Cocoa, respectively.

This means that you can just use the existing tools, like Expression Blend for WPF or Matisse for Swing.

Note, however, that at least for Swing, there is the brilliant scala.swing library, which contains an embedded DSL for building GUIs programmatically. This is not WYSIWYG, so it's not exactly what you are asking for, but I much prefer it, because it is WYMIWYG (What You Mean Is What You Get), which with all the GUI tools I have used so far, seems to be almost impossible to achieve.

like image 191
Jörg W Mittag Avatar answered Oct 05 '22 01:10

Jörg W Mittag


Having build GUIs with JBuilder (and assuming WindowBuilder works on the same principles), it is conceptually possible to develop your bare-bone GUI skeletons (as abstract classes) in Java. Then you can extend or use them from within Scala. It should be easy to pull that off (note I say it should be since I have not done, and I'm purely hypothesizing from related, but not direct experience.)

Case in point, when I develop GUIs, I do create abstract "views", abstract skeletons with the appropriate layouts, visual components, etc, and with pre-defined call-backs for initialization, destruction, make visible/invisible, threading, etc.

Then, I subclass the abstract "view" into a "concrete view" class which does the heavy lifting - registering listeners, GUI logic, etc. Doing things this way requires more elbow grease (sometimes a lot more) than simply mixing GUI layout stuff and logic stuff. But the approach I tend to follow makes a separation of GUI logic and behavior logic. It keeps it clean.

So back to your question: It should be possible to define your "concrete view" class in Scala. With full support for functions as first value objects, closure, lambdas and all the FP goodies, it should be a lot easier to implement listeners and thread action handlers with Scala.

You should give this a try and let us know how it goes (and whether it is feasible or sufficiently easy to make it worthwhile pursuing.)

like image 30
luis.espinal Avatar answered Oct 05 '22 01:10

luis.espinal