61

Please list GUI programming libraries, toolkits, frameworks which allow to write GUI apps quickly. I mean in such a way, that

  • GUI is described entirely in a human-readable (and human-writable) plain text file (code)
  • code is terse (1 or 2 lines of code per widget/event pair), suitable for scripting
  • structure and operation of the GUI is evident from the code (nesting of widgets and flow of events)
  • details about how to build the GUI are hidden (things like mainloop, attaching event listeners, etc.)
  • auto-layouts are supported (vboxes, hboxes, etc.)

As answers suggest, this may be defined as declarative GUI programming, but it is not necessarily such. Any approach is OK if it works, is easy to use and terse.

There are some GUI libraries/toolkits like this. They are listed below. Please extend the list if you see a qualifying toolkit missing. Indicate if the project is crossplatform, mature, active, and give an example if possible.

Please use this wiki to discuss only Open Source projects.

This is the list so far (in alphabetical order):

Fudgets

Fudgets is a Haskell library. Platform: Unix. Status: Experimental, but still maintained. An example:

  import Fudgets
  main = fudlogue (shellF "Hello" (labelF "Hello, world!" >+< quitButtonF))

Fudgets example screenshot
(source: picamatic.com)

GNUstep Renaissance

Renaissance allows to describe GUI in simple XML. Platforms: OSX/GNUstep. Status: part of GNUstep. An example below:

<window title="Example">
  <vbox>
    <label font="big">
      Click the button below to quit the application
    </label>
    <button title="Quit" action="terminate:"/>
  </vbox>
</window> 

Renaissance example screenshot
(source: picamatic.com)

HTML

HTML-based GUI (HTML + JS). Crossplatform, mature. Can be used entirely on the client side.

Looking for a nice “helloworld” example.

HTML GUI example
(source: picamatic.com)

JavaFX

JavaFX is usable for standalone (desktop) apps as well as for web applications. Not completely crossplatform, not yet completely open source. Status: 1.0 release. An example:

  Frame {
    content: Button {
      text: "Press Me"
      action: operation() {
         System.out.println("You pressed me");
      }
    }
    visible: true
  }

Screenshot is needed.

Phooey

Phooey is another Haskell library. Crossplatform (wxWidgets), HTML+JS backend planned. Mature and active. An example (a little more than a helloworld):

  ui1 :: UI ()
  ui1 = title "Shopping List" $
        do a <- title "apples"  $ islider (0,10) 3
           b <- title "bananas" $ islider (0,10) 7
           title "total" $ showDisplay (liftA2 (+) a b)

Phooey example screenshot
(source: picamatic.com)

PythonCard

PythonCard describes GUI in a Python dictionary. Crossplatform (wxWidgets). Some apps use it, but the project seems stalled. There is an active fork.

I skip PythonCard example because it is too verbose for the contest.

PythonCard example screenshot
(source: picamatic.com)

Shoes

Shoes for Ruby. Platforms: Win/OSX/GTK+. Status: Young but active. A minimal app looks like this:

  Shoes.app {
     @push = button "Push me"
     @note = para "Nothing pushed so far"
     @push.click {
        @note.replace "Aha! Click!"
     }
  }

Shoes example screenshot
(source: picamatic.com)

Tcl/Tk

Tcl/Tk. Crossplatform (its own widget set). Mature (probably even dated) and active. An example:

  #!/usr/bin/env wish
  button .hello -text "Hello, World!" -command { exit }
  pack .hello
  tkwait window .

Tcl/Tk example screenshot
(source: picamatic.com)

tekUI

tekUI for Lua (and C). Platforms: X11, DirectFB. Status: Alpha (usable, but API still evolves). An example:

  #/usr/bin/env lua
  ui = require "tek.ui"
  ui.Application:new {
    Children = {
      ui.Window:new  {
        Title = "Hello",
        Children = {
          ui.Text:new {
            Text = "_Hello, World!", Style = "button", Mode = "button",
          },
        },
      },
    },
  }:run()

tekUI helloworld screenshot
(source: picamatic.com)

Treethon

Treethon for Python. It describes GUI in a YAML file (Python in a YAML tree). Platform: GTK+. Status: work in proress. A simple app looks like this:

  _import: gtk
  view: gtk.Window()
  add:
      - view: gtk.Button('Hello World')
        on clicked: print view.get_label()

Treethon helloworld screenshot http://treethon.googlecode.com/svn/trunk/treethon_gtk_tutorial/base.png

Yet unnamed Python library by Richard Jones:

This one is not released yet. The idea is to use Python context managers (with keyword) to structure GUI code. See Richard Jones' blog for details.

with gui.vertical:
    text = gui.label('hello!')
    items = gui.selection(['one', 'two', 'three'])
    with gui.button('click me!'):
        def on_click():
            text.value = items.value
            text.foreground = red

XUL

XUL + Javascript may be used to create stand-alone desktop apps with XULRunner as well as Mozilla extensions. Mature, open source, crossplatform.

  <?xml version="1.0"?>
  <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
  <window id="main" title="My App" width="300" height="300"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    <caption label="Hello World"/>
  </window>

XUL helloworld example
(source: picamatic.com)


Thank your for contributions!

Community
  • 1
  • 1
sastanin
  • 40,473
  • 13
  • 103
  • 130

10 Answers10

16

Not to kid, but HTML.

It's cross-platform, and sums up the gui-layout in a simple textfile. It's definitely mature, as well as well-understood and well documented.

There's a bunch of ways to template HTML files for dynamic content, and other ways to convert custom syntaxes to HTML if you dislike angle-brackets.

Client-side scripting w/ Javascript, server-side scripting with PHP/Ruby/Python/Perl.

It's not well suited for all purposes, but for many, it's good enough. There's no reason that it has to be served either - you can distribute a HTML file to your clients if you want - see TiddlyWiki for a good example of where that can go.

jfs
  • 399,953
  • 195
  • 994
  • 1,670
rampion
  • 87,131
  • 49
  • 199
  • 315
  • 2
    Web-based apps are OK, but the overall complexity of the thing is higher, due to unavoidable client-server interaction. Also, the # of lines of code per “event” is higher even with the latest web and js frameworks. And if an application is not entirely user-request driven, things become more tricky. – sastanin Jan 22 '09 at 21:38
  • I think that HTML is an excellent way to make a GUI. You can make it simple, or fairly complex. I have considered doing this myself for a file dialog, and probably will soon. – Rocketmagnet Jan 22 '09 at 23:24
  • 2
    Your example with TiddlyWiki convinced me that it is suitable for purely client-side GUIs. – sastanin Jan 23 '09 at 09:19
  • I've added a link to http://www.tiddlywiki.com/ – jfs Jan 26 '09 at 00:52
  • HTML... Not enough for heavy CAD-like tools which handle data structures of sizes in range of GBs. Thoughts? – Ninad Sep 13 '11 at 08:02
7

What you're describing is, with the exception of shoes, the new-fangled notion of declarative programming. I'd describe shoes more as a GUI Domain-Specifc Language. Well, I say new-fangled: Visual Basic forms, if you looked behind the IDE designer, were declarative. So, going further back still, were Oracle's SQL*Forms, although assembling them with a text editor was a process only to be be undertaken by the very bravest.

To add another to the list, Microsoft have XAML which, among other things, describes GUIs built for the WPF.

Although some of the schemes mentioned are fairly simple, declaratively-defined GUIs can be as complex as anything defined in code, they're just easier and terser: they say "what" you want to happen and leave it to the underlying framework to handle the "how".

Mike Woodhouse
  • 51,832
  • 12
  • 88
  • 127
  • It is a good answer, to point that all the examples belong to domain-specific languages. Though, I was asking for specific free-as-in-freedom examples. – sastanin Jan 22 '09 at 21:29
  • The point about “declaratively-defined GUIs can be as complex as anything defined in code, they're jsut easier and terser” is very true in my opinion. – sastanin Jan 22 '09 at 21:52
  • Would this mean that Shoes has got the better architecture among the rest? – Ninad Sep 13 '11 at 08:07
  • 1
    @Ninad I don't know about "better" - shoes (which may be better viewed in its [green shoes](https://github.com/ashbb/green_shoes) incarnation which is supported and in continuing development) can be tricky to coax into more complex, form-like structures. But that's probably true for most "simple" frameworks. I think it's just a matter of finding what works best for the individual. – Mike Woodhouse Sep 13 '11 at 09:15
6

TCL/TK is a script language used for building GUI interactively. It is available on various platforms including Unix, Windows and Mac OS X.

mouviciel
  • 66,855
  • 13
  • 106
  • 140
  • 1
    I know about Tk. It is terse indeed. But one thing that makes me avoid it is that Tk applications still look as “ugly” on my Linux box, as they did few years ago. I'm not talking about a different widget set, but about the fonts. Tought, probably, it is not a problem of Tk itself, but of my distro… – sastanin Jan 22 '09 at 21:50
  • Tile native themes make Tcl/Tk look pretty again. There are even themes to make it look like Gtk or Qt http://wiki.tcl.tk/11075 – Daniel Lopez Jan 24 '09 at 22:59
  • I think this answer deserves a higher vote, but I cannot upvote it anymore... – sastanin Jan 30 '09 at 10:09
  • 3
    The issue with fonts has been addressed in the latest versions of Tk which now support anti-aliased fonts. Personally I'm more concerned about functionality and productivity in a UI toolkit rather than with pretty fonts, and in that regard Tk has almost no peer. – Bryan Oakley Mar 10 '09 at 15:35
3

Pyjamas - http://pyjs.org - it's a desktop widget set, disguised as an AJAX-based web 2.0 widget set. it's so very much NOT like a web widget set that i actually ported it to the desktop - http://pyjd.org - using webkit (the same engine in adobe AIR, google chrome, safari etc.)

this is "hello world":

from pyjamas.ui.RootPanel import RootPanel
from pyjamas.ui.Button import Button
from pyjamas import Window

def greet(fred):
    Window.alert("Hello, AJAX!")

if __name__ == '__main__':
    b = Button("Click me", greet)
    RootPanel().add(b)

that immediately answers the first four out of five requirements. requirement 5 is fulfilled by this:

from pyjamas.ui.RootPanel import RootPanel
from pyjamas.ui.HorizontalPanel import HorizontalPanel
from pyjamas.ui.HTML import HTML

p = HorizontalPanel()
p.add(HTML("<b>Hello</b>"))
p.add(HTML("World"))
RootPanel().add(p)

it couldn't get any simpler.

2

SDL/Swing is extremely terse, readable, unobtrusive (283k lib with no dependencies) and easy to use. Example:

menus {
    "File" {
        "Open" do="open" // calls "open()" in the controller
        "---"
        "Exit" do="exit"
    }
}

Its open source but enjoys commercial support from Ikayzo.com. Ports for .NET and iOS are underway.

2

XUL (it's pretty easy to use, and powerful -- much of Firefox is implemented using XUL for GUI structure, + javascript for logic handling)

The XUL tutorial has some good examples. Here's one for tabboxes. The one at the bottom of the page has switchable tabs, buttons, edit boxes, and group boxes, and it's fairly simple (no Javascript/CSS/XBL/key bindings/etc). They then add progressively more stuff later which is a lot of functionality for the length of the file that specifies it. (at least until you start adding javascript to handle the logic in question) If I had to do something like this in Win32 it would be a real pain.

Jason S
  • 184,598
  • 164
  • 608
  • 970
  • I didn't see any easy-to-use examles of XUL use outside of Mozilla. Browsing through its Tutorial gives an impression that it is too XMLish and too verbose to be used for quick and simple GUI development. I would appreciate if you can prove the opposite. – sastanin Jan 22 '09 at 21:44
  • I guess I don't have much to compare it to, other than the various win32 tools I've used, and MATLAB's GUI; from that viewpoint I've found XUL very easy. Probably your best bet is to look at one of the Firefox extensions that uses it. (lemme find one...) – Jason S Jan 22 '09 at 23:02
  • i mean there's this example... http://www.ibm.com/developerworks/web/library/wa-xul1/ – Jason S Jan 22 '09 at 23:03
  • Your examples with tabboxes and FF extensions are convincing. I'll consider it. – sastanin Jan 23 '09 at 08:25
  • I've also found a tutorial about building stand along apps with XULRunner: https://developer.mozilla.org/en/Getting_started_with_XULRunner – sastanin Jan 23 '09 at 08:32
  • Yeah I forgot to mention XULRunner. :) I guess that's kind of important. I've never tried it, I've always used Firefox to run my XUL (with the disadvantage that if your program crashes it takes down the browser :/ ) – Jason S Jan 23 '09 at 14:18
2

wxLua is a wrapper of the wxWidgets library for Lua. It uses a Connect method to attach gui widget events to functions (functions are first class like in JS).

Nick Van Brunt
  • 15,244
  • 11
  • 66
  • 92
2

GTK-server is extremely simple to use and can be used from more than 30 languages, including Bash and Visual Basic.

Jakob Eriksson
  • 33
  • 1
  • 1
  • 6
  • Interesting project! I never thought about accessing a real API via unixy interfaces -- my experience in commandline-driven GUIs was basically limited to kdialog. I wonder if this can be generalized to work with any API. –  Mar 17 '09 at 14:59
  • 1
    It is certainly very interesting. It seems to be nice for scripting-controlled GUI, but it does not look “terse”. Thank you! – sastanin Mar 18 '09 at 16:35
  • How can it be much more terse than this: http://www.gtk-server.org/demo-stdin.py.txt ? And just to clarify, gtk-server works on Windows too, which opens up for things like running the GUI on Windows, but logic on Linux, but I digress... – Jakob Eriksson Mar 25 '09 at 11:43
  • You may as well say GTK. Unless I'm misunderstanding something, it's just dynamically processed C code from strings. It appears to be more complicated than the equivalent C code; which isn't what I'd call an ideal GUI framework. – mbauman May 30 '10 at 05:44
1

I juat came across SDL/Swing today.

Digikata
  • 1,821
  • 17
  • 25
  • 1
    Looks like an interesting domain-specific language. Just a note for who doesn't follow links: SDL is not for Simple Directmedia Layer here. – sastanin May 26 '10 at 14:11
-2

You should have a look at XAML if you're on the .NET platform

Rad
  • 8,336
  • 4
  • 46
  • 45
  • 1
    It is not free (open source). And even though there is a XAML compiler for Mono (http://developer.novell.com/wiki/index.php/Xaml_compiler_for_mono), I am not sure if it is 100% compatible, or will remain such. – sastanin Jan 28 '09 at 10:03